semiotic 3.2.3 → 3.3.0

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.
Files changed (53) hide show
  1. package/CLAUDE.md +118 -264
  2. package/README.md +37 -17
  3. package/ai/schema.json +1 -1
  4. package/ai/system-prompt.md +3 -3
  5. package/dist/components/charts/ordinal/SwimlaneChart.d.ts +4 -0
  6. package/dist/components/charts/realtime/RealtimeHeatmap.d.ts +2 -0
  7. package/dist/components/charts/realtime/RealtimeHistogram.d.ts +2 -0
  8. package/dist/components/charts/realtime/RealtimeLineChart.d.ts +2 -0
  9. package/dist/components/charts/realtime/RealtimeSwarmChart.d.ts +2 -0
  10. package/dist/components/charts/realtime/RealtimeWaterfallChart.d.ts +2 -0
  11. package/dist/components/charts/shared/hooks.d.ts +2 -1
  12. package/dist/components/charts/shared/types.d.ts +6 -2
  13. package/dist/components/charts/shared/useChartSetup.d.ts +1 -1
  14. package/dist/components/realtime/RingBuffer.d.ts +11 -0
  15. package/dist/components/realtime/types.d.ts +4 -0
  16. package/dist/components/semiotic-server.d.ts +6 -1
  17. package/dist/components/server/animatedGif.d.ts +78 -0
  18. package/dist/components/server/renderToStaticSVG.d.ts +85 -5
  19. package/dist/components/server/staticAnnotations.d.ts +40 -0
  20. package/dist/components/server/staticLegend.d.ts +39 -0
  21. package/dist/components/server/svgHatchPattern.d.ts +26 -0
  22. package/dist/components/server/themeResolver.d.ts +35 -0
  23. package/dist/components/stream/GeoPipelineStore.d.ts +6 -1
  24. package/dist/components/stream/NetworkPipelineStore.d.ts +20 -0
  25. package/dist/components/stream/OrdinalPipelineStore.d.ts +11 -0
  26. package/dist/components/stream/OrdinalSVGOverlay.d.ts +5 -0
  27. package/dist/components/stream/PipelineStore.d.ts +11 -0
  28. package/dist/components/stream/accessorUtils.d.ts +3 -3
  29. package/dist/components/stream/geoTypes.d.ts +2 -0
  30. package/dist/components/stream/networkTypes.d.ts +33 -0
  31. package/dist/components/stream/ordinalTypes.d.ts +30 -3
  32. package/dist/components/stream/renderers/resolveCSSColor.d.ts +17 -0
  33. package/dist/components/stream/types.d.ts +4 -0
  34. package/dist/geo.min.js +1 -1
  35. package/dist/geo.module.min.js +1 -1
  36. package/dist/network.min.js +1 -1
  37. package/dist/network.module.min.js +1 -1
  38. package/dist/ordinal.min.js +1 -1
  39. package/dist/ordinal.module.min.js +1 -1
  40. package/dist/realtime.min.js +1 -1
  41. package/dist/realtime.module.min.js +1 -1
  42. package/dist/semiotic-ai.min.js +1 -1
  43. package/dist/semiotic-ai.module.min.js +1 -1
  44. package/dist/semiotic-server.d.ts +6 -1
  45. package/dist/semiotic-utils.min.js +1 -1
  46. package/dist/semiotic-utils.module.min.js +1 -1
  47. package/dist/semiotic.min.js +1 -1
  48. package/dist/semiotic.module.min.js +1 -1
  49. package/dist/server.min.js +1 -1
  50. package/dist/server.module.min.js +1 -1
  51. package/dist/xy.min.js +1 -1
  52. package/dist/xy.module.min.js +1 -1
  53. package/package.json +14 -3
@@ -1 +1 @@
1
- import*as e from"react";import{useRef as t,useState as n,useEffect as o,useMemo as r,useSyncExternalStore as i,createContext as a,useContext as s,useCallback as l,forwardRef as c,useImperativeHandle as u,useId as d}from"react";import{geoPath as p,geoGraticule as h,geoDistance as y,geoInterpolate as g,geoEqualEarth as f,geoEquirectangular as m,geoNaturalEarth1 as b,geoOrthographic as v,geoAlbersUsa as x,geoMercator as k}from"d3-geo";import{scaleLinear as w,scaleOrdinal as A,scaleSequential as j}from"d3-scale";import{bin as E,extent as O}from"d3-array";import{packEnclose as S}from"d3-hierarchy";import{area as M,curveCatmullRom as C,curveCardinal as $,curveBasis as z,curveStepBefore as L,curveStepAfter as P,curveStep as I,curveMonotoneY as B,curveMonotoneX as N,curveLinear as D,line as T,curveNatural as R}from"d3-shape";import W from"regression";import{zoomIdentity as F,zoom as _}from"d3-zoom";import{select as H}from"d3-selection";import{schemeCategory10 as q,interpolatePlasma as G,interpolateViridis as V,interpolatePurples as U,interpolateOranges as Z,interpolateGreens as Y,interpolateReds as X,interpolateBlues as K,schemeSet3 as J,schemeTableau10 as Q}from"d3-scale-chromatic";class ee{constructor(e){if(this._capacity=e,this.head=0,this._size=0,1>e)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(e)}push(e){let t;return this._size===this._capacity?t=this.buffer[this.head]:this._size++,this.buffer[this.head]=e,this.head=(this.head+1)%this._capacity,t}pushMany(e){const t=[];for(const n of e){const e=this.push(n);void 0!==e&&t.push(e)}return t}get(e){if(e>=0&&this._size>e)return this.buffer[(this.head-this._size+e+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let e=0;const t=this;return{next:()=>t._size>e?{done:!1,value:t.get(e++)}:{done:!0,value:void 0}}}forEach(e){const t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e(this.buffer[(t+n)%this._capacity],n)}toArray(){const e=Array(this._size),t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e[n]=this.buffer[(t+n)%this._capacity];return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray(),n=[];for(;t.length>e;)n.push(t.shift());this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(const e of t)this.push(e);return n}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}}function te(e,t,n){return e+(t-e)*n}const ne={mercator:k,equalEarth:f,albersUsa:x,orthographic:v,naturalEarth:b,equirectangular:m};function oe(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}function re(e){return e?"function"==typeof e?e:t=>t[e]:e=>e.coordinates||e.data||[]}function ie(e,t,n){return e?Object.assign(Object.assign({},n),"function"==typeof e?e(t):e):n}const ae={fill:"#e0e0e0",stroke:"#999",strokeWidth:.5,fillOpacity:1},se={fill:"#4e79a7",r:4,fillOpacity:.8},le={stroke:"#4e79a7",strokeWidth:1.5,fill:"none"};function ce(e,t){if(2>e.length)return[e];const n=.4*t,o=[];let r=[e[0]];for(let t=1;e.length>t;t++){const i=e[t];Math.abs(i[0]-e[t-1][0])>n?(2>r.length||o.push(r),r=[i]):r.push(i)}return 2>r.length||o.push(r),o}function ue(e,t,n=24){const o=t[0]-e[0],r=t[1]-e[1],i=Math.sqrt(o*o+r*r);if(0===i)return[e,t];const a=-r/i,s=o/i,l=Math.min(.3*i,80),c=(e[0]+t[0])/2+a*l,u=(e[1]+t[1])/2+s*l,d=[];for(let o=0;n>=o;o++){const r=o/n,i=1-r;d.push([i*i*e[0]+2*i*r*c+r*r*t[0],i*i*e[1]+2*i*r*u+r*r*t[1]])}return d}function de(e,t){if(2>e.length)return e;const n=t/2+1,o=[];for(let t=0;e.length>t;t++){const r=e[t];let i,a;0===t?(i=e[1][0]-r[0],a=e[1][1]-r[1]):t===e.length-1?(i=r[0]-e[t-1][0],a=r[1]-e[t-1][1]):(i=e[t+1][0]-e[t-1][0],a=e[t+1][1]-e[t-1][1]);const s=Math.sqrt(i*i+a*a)||1;o.push([r[0]+a/s*n,r[1]+-i/s*n])}return o}function pe(e,t,n,o,r){const i=t[0]-e[0],a=t[1]-e[1],s=Math.sqrt(i*i+a*a);if(0===s)return[e,t];const l=a/s,c=-i/s,u=r/2+1;return[[e[0]+l*u,e[1]+c*u],[t[0]+l*u,t[1]+c*u]]}class he{constructor(e){this.scene=[],this.scales=null,this.version=0,this.projection=null,this.geoPath=null,this.baseScale=0,this.baseTranslate=[0,0],this.baseRotation=[0,0,0],this.currentZoom=1,this.cartogramLayout=null,this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.streaming=!1,this.lastIngestTime=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositions=null,this.config=e}updateConfig(e){this.config=Object.assign(Object.assign({},this.config),e)}setAreas(e){this.areas=e}setPoints(e){this.pointData=e,this.streaming=!1}setLines(e){this.lineData=e}initStreaming(e=500){this.pointBuffer=new ee(e),this.timestampBuffer=new ee(e),this.streaming=!0}pushPoint(e){this.pointBuffer||this.initStreaming(),this.pointBuffer.push(e),this.timestampBuffer.push(performance.now()),this.lastIngestTime=performance.now()}pushMany(e){this.pointBuffer||this.initStreaming();const t=performance.now();for(const n of e)this.pointBuffer.push(n),this.timestampBuffer.push(t);this.lastIngestTime=t}clear(){this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.timestampBuffer=null,this.scene=[],this.scales=null,this.version++}computeScene(e){const{config:t}=this;this.projection=function(e){if(!e)return f();if("string"==typeof e){const t=ne[e];return t?t():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${e}", falling back to equalEarth`),f())}if("object"==typeof e&&"type"in e){const t=ne[e.type],n=t?t():f();return e.rotate&&"rotate"in n&&n.rotate(e.rotate),e.center&&"center"in n&&n.center(e.center),n}return e}(t.projection),this.geoPath=p(this.projection),this.fitProjection(e),this.geoPath=p(this.projection);const n=this.projection;this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(e,t)=>n([e,t]),invertedPoint:(e,t)=>n.invert?n.invert([e,t]):null};const o=this.scene;this.scene=this.buildSceneNodes(e),t.projectionTransform&&this.applyCartogramTransform(t.projectionTransform,e),t.decay&&this.streaming&&this.applyDecay(),t.pulse&&this.streaming&&this.applyPulse(),t.transition&&o.length>0&&this.startTransition(o),this.version++}fitProjection(e){var t,n,o,r,i;const a=this.projection,s=this.config,l=[...this.areas],c=oe(s.xAccessor,"lon"),u=oe(s.yAccessor,"lat"),d=this.getPoints();if(d.length>0){const e=d.map(e=>[c(e),u(e)]);l.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:e}})}const p=re(s.lineDataAccessor);for(const e of this.lineData){const t=p(e);if(t&&t.length>0){const e=t.map(e=>[c(e),u(e)]);l.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:e}})}}if(0!==l.length){if(s.projectionExtent){const[[t,n],[o,r]]=s.projectionExtent;a.fitExtent([[0,0],[e.width,e.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[t,n],[o,n],[o,r],[t,r],[t,n]]]}})}else if(a.clipAngle&&(null!==(t=a.clipAngle())&&void 0!==t?t:0)>0){const t=null!==(n=s.fitPadding)&&void 0!==n?n:0,o=Math.min(e.width,e.height);a.scale(o/2-o*t),a.translate([e.width/2,e.height/2])}else{const t=null!==(o=s.fitPadding)&&void 0!==o?o:0,n=e.width*t,r=e.height*t;a.fitExtent([[n,r],[e.width-n,e.height-r]],{type:"FeatureCollection",features:l})}this.baseScale=a.scale(),this.baseTranslate=a.translate(),this.baseRotation=null!==(i=null===(r=a.rotate)||void 0===r?void 0:r.call(a))&&void 0!==i?i:[0,0,0]}}applyZoomTransform(e,t){const n=this.projection;n&&(n.scale(this.baseScale*e.k),n.translate([this.baseTranslate[0]*e.k+e.x,this.baseTranslate[1]*e.k+e.y]),this.currentZoom=e.k,this.geoPath=p(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(e,t)=>n([e,t]),invertedPoint:(e,t)=>n.invert?n.invert([e,t]):null},this.scene=this.buildSceneNodes(t),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}applyZoomScale(e,t){const n=this.projection;n&&(n.scale(this.baseScale*e),n.translate(this.baseTranslate),this.currentZoom=e,this.geoPath=p(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(e,t)=>n([e,t]),invertedPoint:(e,t)=>n.invert?n.invert([e,t]):null},this.scene=this.buildSceneNodes(t),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}applyRotation(e,t){const n=this.projection;n&&n.rotate&&(n.rotate(e),this.geoPath=p(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(e,t)=>n([e,t]),invertedPoint:(e,t)=>n.invert?n.invert([e,t]):null},this.scene=this.buildSceneNodes(t),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}setRotation(e){const t=this.projection;t&&t.rotate&&t.rotate(e)}getRotation(){var e,t,n;return null!==(n=null===(t=null===(e=this.projection)||void 0===e?void 0:e.rotate)||void 0===t?void 0:t.call(e))&&void 0!==n?n:this.baseRotation}getBaseProjectionState(){return{scale:this.baseScale,translate:[...this.baseTranslate]}}getPoints(){return this.streaming&&this.pointBuffer?this.pointBuffer.toArray():this.pointData}buildSceneNodes(e){var t,n,o;const r=[],{config:i}=this,a=this.projection,s=this.geoPath,l=oe(i.xAccessor,"lon"),c=oe(i.yAccessor,"lat");if(i.graticule){const t=!0===i.graticule?{}:i.graticule,n=h();t.step&&n.step(t.step);const o=s(n())||"";o&&r.push({type:"geoarea",pathData:o,centroid:[e.width/2,e.height/2],bounds:[[0,0],[e.width,e.height]],screenArea:0,style:{fill:"none",stroke:t.stroke||"#e0e0e0",strokeWidth:t.strokeWidth||.5,strokeDasharray:t.strokeDasharray||"2,2"},datum:null,interactive:!1})}for(const e of this.areas){const t=s(e);if(!t)continue;const n=s.centroid(e),o=s.bounds(e),a=s.area(e),l=ie(i.areaStyle,e,ae);r.push({type:"geoarea",pathData:t,centroid:n,bounds:o,screenArea:a,style:l,datum:e,interactive:!0})}const u=re(i.lineDataAccessor);for(const t of this.lineData){const n=u(t);if(!n||2>n.length)continue;const o=n.map(e=>[l(e),c(e)]);let s;if("geo"===i.lineType){const e=[];for(let t=0;o.length-1>t;t++){const n=o[t],r=o[t+1],i=y(n,r)||0,a=Math.max(2,Math.ceil(i/(Math.PI/180))),s=g(n,r);for(let n=0;a>=n;n++)t>0&&0===n||e.push(s(n/a))}s=e.map(([e,t])=>a([e,t])).filter(e=>null!=e)}else s=o.map(([e,t])=>a([e,t])).filter(e=>null!=e);if(2>s.length)continue;const d=ie(i.lineStyle,t,le),p="number"==typeof d.strokeWidth?d.strokeWidth:1;2!==o.length||2>s.length||"arc"!==i.flowStyle?2!==o.length||2>s.length||"offset"!==i.flowStyle||(s="geo"===i.lineType?de(s,p):pe(s[0],s[s.length-1],0,0,p)):s=ue(s[0],s[s.length-1]);const h=ce(s,e.width);if(h.length>1)for(const e of h){if(2>e.length)continue;const n={type:"line",path:e,style:Object.assign(Object.assign({},d),{_edgeFade:!0}),datum:t};r.push(n)}else r.push({type:"line",path:2>s.length&&h[0]||s,style:d,datum:t})}const d=this.getPoints(),p=i.pointIdAccessor?"function"==typeof i.pointIdAccessor?i.pointIdAccessor:e=>e[i.pointIdAccessor]:null,f=a.clipAngle&&null!==(t=a.clipAngle())&&void 0!==t?t:0,m=f>0?f*Math.PI/180:null,b=a.rotate?a.rotate():[0,0,0],v="function"==typeof a.center?a.center():[0,0],x=[(null!==(n=v[0])&&void 0!==n?n:0)-b[0],(null!==(o=v[1])&&void 0!==o?o:0)-b[1]];for(let e=0;d.length>e;e++){const t=d[e],n=l(t),o=c(t);if(null!=m&&y([n,o],x)>m)continue;const s=a([n,o]);if(!s)continue;const u=i.pointStyle?i.pointStyle(t):Object.assign({},se),h={type:"point",x:s[0],y:s[1],r:u.r||4,style:u,datum:t,pointId:p?p(t)+"":void 0};r.push(h)}return r}applyCartogramTransform(e,t){var n,o,r;const i=this.scene.filter(e=>"point"===e.type);if(2>i.length)return;const a=null!==(n=e.strength)&&void 0!==n?n:1;if(0===a)return;const s=e.centerAccessor?"function"==typeof e.centerAccessor?e.centerAccessor:t=>t[e.centerAccessor]:e=>e.id,l="function"==typeof e.costAccessor?e.costAccessor:t=>t[e.costAccessor],c=i.find(t=>s(t.datum)+""==e.center+"");if(!c)return void("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${e.center}" not found in point data`));const u=c.x,d=c.y,p=i.map(e=>l(e.datum)).filter(e=>isFinite(e)&&e>=0),h=Math.max(...p,1),y=Math.min(t.width,t.height)/2,g=w().domain([0,h]).range([0,y]);this.cartogramLayout={cx:u,cy:d,maxCost:h,availableRadius:y},this.areas.length>0&&"production"!==process.env.NODE_ENV&&console.warn("GeoFrame: Distance cartogram does not support area rendering. Areas will be ignored. Remove areas or set projectionTransform to null to render them."),this.scene=this.scene.filter(e=>"geoarea"!==e.type||!e.interactive);for(const e of i){if(e===c)continue;const t=Math.atan2(e.y-d,e.x-u),n=Math.sqrt(Math.pow(e.x-u,2)+Math.pow(e.y-d,2)),o=l(e.datum),r=n+((isFinite(o)?g(o):n)-n)*a;e.x=u+Math.cos(t)*r,e.y=d+Math.sin(t)*r}const f=t.width/2,m=t.height/2,b=f-c.x,v=m-c.y;if(Math.abs(b)>.5||Math.abs(v)>.5)for(const e of i)e.x+=b,e.y+=v;this.cartogramLayout={cx:f,cy:m,maxCost:h,availableRadius:y};const x=this.scene.filter(e=>"line"===e.type);if(x.length>0&&"fractional"!==e.lineMode){const e=new Map;for(const t of i)t.pointId&&e.set(t.pointId,[t.x,t.y]);for(const t of x){const n=null===(o=t.datum)||void 0===o?void 0:o.source,i=null===(r=t.datum)||void 0===r?void 0:r.target;if(n&&i){const o=e.get(n+""),r=e.get(i+"");o&&r&&(t.path=[o,r])}}}}applyDecay(){var e,t,n;const o=this.config.decay;if(!o||!this.pointBuffer)return;const r=this.pointBuffer.size;if(0===r)return;const i=null!==(e=o.minOpacity)&&void 0!==e?e:.1,a=null!==(t=o.halfLife)&&void 0!==t?t:r/2,s=null!==(n=o.stepThreshold)&&void 0!==n?n:.5*r,l=this.scene.filter(e=>"point"===e.type);for(let e=0;l.length>e;e++){const t=r-1-e;let n;switch(o.type){case"exponential":n=i+Math.pow(.5,t/a)*(1-i);break;case"step":n=s>t?1:i;break;default:n=i+(r>1?1-t/(r-1):1)*(1-i)}l[e]._decayOpacity=n,l[e].style=Object.assign(Object.assign({},l[e].style),{opacity:n})}}applyPulse(){var e,t;const n=this.config.pulse;if(!n||!this.timestampBuffer)return;const o=null!==(e=n.duration)&&void 0!==e?e:500,r=performance.now(),i=this.scene.filter(e=>"point"===e.type),a=this.timestampBuffer.toArray();for(let e=0;i.length>e&&a.length>e;e++){const s=r-a[e];o>s&&(i[e]._pulseIntensity=1-s/o,i[e]._pulseColor=n.color||"rgba(255,255,255,0.6)",i[e]._pulseGlowRadius=null!==(t=n.glowRadius)&&void 0!==t?t:4)}}get hasActivePulses(){var e,t;if(!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const n=null!==(t=null===(e=this.config.pulse)||void 0===e?void 0:e.duration)&&void 0!==t?t:500,o=this.timestampBuffer.toArray()[this.timestampBuffer.size-1];return performance.now()-o<n}startTransition(e){var t,n;const o=null!==(n=null===(t=this.config.transition)||void 0===t?void 0:t.duration)&&void 0!==n?n:300;if(0>=o)return;const r=new Map;for(const t of e)"point"===t.type&&t.pointId&&r.set(t.pointId,[t.x,t.y]);const i=this.scene.filter(e=>"point"===e.type);let a=!1;for(const e of i)if(e.pointId){const t=r.get(e.pointId);t&&(e._targetX=e.x,e._targetY=e.y,e.x=t[0],e.y=t[1],(Math.abs(t[0]-e._targetX)>.5||Math.abs(t[1]-e._targetY)>.5)&&(a=!0))}a&&(this.activeTransition={startTime:performance.now(),duration:o})}advanceTransition(e){if(!this.activeTransition)return!1;const t=function(e,t){return Math.min((e-t.startTime)/t.duration,1)}(e,this.activeTransition),n=function(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}(t),o=this.scene.filter(e=>"point"===e.type);for(const e of o)if(null!=e._targetX&&null!=e._targetY){const t=e.y;e.x=te(e.x,e._targetX,n),e.y=te(t,e._targetY,n)}if(t>=1){for(const e of o)null!=e._targetX&&(e.x=e._targetX,e.y=e._targetY,e._targetX=void 0,e._targetY=void 0);return this.activeTransition=null,!1}return!0}}function ye(e,t=30){return Math.max((null!=e?e:4)+5,12,t)}function ge(e){return e instanceof Date?e:"number"==typeof e&&e>1e9?new Date(e):null}function fe(e,t){const n=ge(e);if(!n)return!1;const o=ge(t);return!o||n.getFullYear()!==o.getFullYear()||n.getMonth()!==o.getMonth()}function me(e,t,n,o,r,i){const a=e.filter(e=>"point"===e.type);let s=null,l=o;for(const e of a){const r=e.x-t,i=e.y-n,a=Math.sqrt(r*r+i*i);ye(e.r,o)>=a&&l>a&&(s=e,l=a)}if(s)return{node:s,distance:l};const c=e.filter(e=>"geoarea"===e.type&&!1!==e.interactive);for(let e=c.length-1;e>=0;e--){const o=c[e],[[i,a],[s,l]]=o.bounds;if(!(i>t||t>s||a>n||n>l)&&(o._cachedPath2D||(o._cachedPath2D=new Path2D(o.pathData)),r.isPointInPath(o._cachedPath2D,t,n)))return{node:o,distance:0}}const u=e.filter(e=>"line"===e.type);let d=null,p=o;for(const e of u){const{path:o}=e;for(let r=0;o.length-1>r;r++){const[i,a]=o[r],[s,l]=o[r+1],c=be(t,n,i,a,s,l);Math.max((e.style.strokeWidth||2)+4,5)>=c&&p>c&&(d=e,p=c)}}return d?{node:d,distance:p}:null}function be(e,t,n,o,r,i){const a=r-n,s=i-o,l=a*a+s*s;if(0===l)return Math.sqrt(Math.pow(e-n,2)+Math.pow(t-o,2));let c=((e-n)*a+(t-o)*s)/l;c=Math.max(0,Math.min(1,c));const u=o+c*s;return Math.sqrt(Math.pow(e-(n+c*a),2)+Math.pow(t-u,2))}const ve={fill:t=>e.createElement("rect",{style:t,width:16,height:16}),line:t=>e.createElement("line",{style:t,x1:0,y1:0,x2:16,y2:16})};function xe(e,t,n,o){let r;return r="function"==typeof n?n(e):(0,ve[n])(o(e,t)),r}function ke(){return e.createElement("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function we(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}function Ae({config:t,orientation:n="vertical",width:o=100}){const{colorFn:r,domain:i,label:a,format:s}=t,l=s||(e=>Math.round(100*e)/100+""),c="grad-legend-"+e.useId();if("horizontal"===n){const t=12,n=Math.min(o,200),s=Math.max(0,(o-n)/2),u=[];for(let t=0;64>=t;t++){const n=t/64;u.push(e.createElement("stop",{key:t,offset:100*n+"%",stopColor:r(i[0]+n*(i[1]-i[0]))}))}return e.createElement("g",{"aria-label":a||"Gradient legend"},e.createElement("defs",null,e.createElement("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"100%",y2:"0%"},u)),a&&e.createElement("text",{x:s+n/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},a),e.createElement("rect",{x:s,y:0,width:n,height:t,fill:`url(#${c})`,rx:2}),e.createElement("text",{x:s,y:t+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},l(i[0])),e.createElement("text",{x:s+n,y:t+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},l(i[1])))}const u=[];for(let t=0;64>=t;t++){const n=t/64;u.push(e.createElement("stop",{key:t,offset:100*n+"%",stopColor:r(i[1]-n*(i[1]-i[0]))}))}return e.createElement("g",{"aria-label":a||"Gradient legend"},a&&e.createElement("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},a),e.createElement("defs",null,e.createElement("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"0%",y2:"100%"},u)),e.createElement("rect",{x:0,y:0,width:14,height:100,fill:`url(#${c})`,rx:2}),e.createElement("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},l(i[1])),e.createElement("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},l(i[0])))}function je(t){const{legendGroups:n,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:a,legendInteraction:s,title:l="Legend",width:c=100,height:u=20,orientation:d="vertical"}=t,[p,h]=e.useState(0),[y,g]=e.useState(0),f=e.useCallback((e,t)=>{h(e),g(t)},[]),m="vertical"===d?(({legendGroups:t,width:n,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:a,focusedGroupIndex:s,focusedItemIndex:l,onFocusedIndexChange:c,legendInteraction:u})=>{let d=24;const p=[];return t.forEach((t,h)=>{d+=5,p.push(e.createElement("line",{key:"legend-top-line legend-symbol-"+h,stroke:"gray",x1:0,y1:d,x2:n,y2:d})),d+=8,t.label&&(d+=16,p.push(e.createElement("text",{key:"legend-text-"+h,y:d,className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},t.label)),d+=8),p.push(e.createElement("g",{key:"legend-group-"+h,className:"legend-item",transform:`translate(0,${d})`},((t,n,o,r,i,a,s,l,c,u)=>{const{type:d="fill",styleFn:p,items:h}=t,y=[];let g=0;const f=!(!n&&!o),m="isolate"===u||void 0===u&&null!=i;return h.forEach((t,u)=>{const b=xe(t,u,d,p),v=we(t,r,i),x=i&&i.size>0&&i.has(t.label);y.push(e.createElement("g",{key:"legend-item-"+u,transform:`translate(0,${g})`,onClick:n?()=>n(t):void 0,onMouseEnter:o?()=>o(t):void 0,onMouseLeave:o?()=>o(null):void 0,tabIndex:f?l===a&&u===s?0:-1:void 0,role:f?"option":void 0,"aria-selected":f&&m?x||!1:void 0,"aria-current":f&&!m&&null!=r&&t.label===r||void 0,"aria-label":t.label,onKeyDown:f?e=>{var o;if("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),n&&n(t)),"ArrowDown"===e.key||"ArrowUp"===e.key){e.preventDefault();const t=(u+("ArrowDown"===e.key?1:-1)+h.length)%h.length;c(l,t);const n=null===(o=e.currentTarget.parentElement)||void 0===o?void 0:o.children[t];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:f?e=>{c(l,u),o&&o(t);const n=e.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:f?e=>{o&&o(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:f?"pointer":"default",opacity:v,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},f&&e.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*t.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),b,x&&e.createElement(ke,null),e.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},t.label))),g+=22}),y})(t,o,r,i,a,s,l,h,c,u))),d+=22*t.items.length+8}),p})({legendGroups:n||[],width:c,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:a,focusedGroupIndex:p,focusedItemIndex:y,onFocusedIndexChange:f,legendInteraction:s}):(({legendGroups:t,height:n,width:o,customClickBehavior:r,customHoverBehavior:i,highlightedCategory:a,isolatedCategories:s,focusedGroupIndex:l,focusedItemIndex:c,onFocusedIndexChange:u,legendInteraction:d})=>{let p=0;const h=[];t.forEach((t,n)=>{let y=0;t.label&&(y+=16);const g=((t,n,o,r,i,a,s,l,c,u,d)=>{const{type:p="fill",styleFn:h,items:y}=t,g=[];let f=0,m=0;const b=!(!n&&!o),v="isolate"===u||void 0===u&&null!=i;y.forEach((t,u)=>{const x=xe(t,u,p,h),k=we(t,r,i),w=i&&i.size>0&&i.has(t.label),A=26+7*t.label.length;d&&d>0&&f>0&&f+A>d&&(m++,f=0),g.push(e.createElement("g",{key:"legend-item-"+u,transform:`translate(${f},${22*m})`,onClick:n?()=>n(t):void 0,onMouseEnter:o?()=>o(t):void 0,onMouseLeave:o?()=>o(null):void 0,tabIndex:b?l===a&&u===s?0:-1:void 0,role:b?"option":void 0,"aria-selected":b&&v?w||!1:void 0,"aria-current":b&&!v&&null!=r&&t.label===r||void 0,"aria-label":t.label,onKeyDown:b?e=>{var o;if("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),n&&n(t)),"ArrowRight"===e.key||"ArrowLeft"===e.key){e.preventDefault();const t=(u+("ArrowRight"===e.key?1:-1)+y.length)%y.length;c(l,t);const n=null===(o=e.currentTarget.parentElement)||void 0===o?void 0:o.children[t];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:b?e=>{c(l,u),o&&o(t);const n=e.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:b?e=>{o&&o(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:b?"pointer":"default",opacity:k,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},b&&e.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*t.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),x,w&&e.createElement(ke,null),e.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},t.label))),f+=A});let x=0,k=0;for(const e of y){const t=26+7*e.label.length;d&&d>0&&k>0&&k+t>d?(x=Math.max(x,k),k=t):k+=t}x=Math.max(x,k);const w=m+1;return{items:g,offset:x,totalRows:w,totalHeight:22*w}})(t,r,i,a,s,l,c,n,u,d,o);y+=g.offset+5,h.push(Object.assign(Object.assign({label:t.label},g),{offset:y,totalRows:g.totalRows,totalHeight:g.totalHeight})),p+=y+12});let y=p>o?0:Math.max(0,(o-p)/2);const g=[];return h.forEach((o,r)=>{const i=t[r];i.label&&(g.push(e.createElement("text",{key:"legend-text-"+r,transform:`translate(${y},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},i.label)),y+=16),g.push(e.createElement("g",{key:"legend-group-"+r,className:"legend-item",transform:`translate(${y},0)`},o.items)),y+=o.offset+5,t[r+1]&&g.push(e.createElement("line",{key:"legend-top-line legend-symbol-"+r,stroke:"gray",x1:y,y1:-8,x2:y,y2:(o.totalHeight||n)+0+8})),y+=12}),e.createElement("g",null,g)})({legendGroups:n||[],title:l,height:u,width:c,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:a,focusedGroupIndex:p,focusedItemIndex:y,onFocusedIndexChange:f,legendInteraction:s}),b=!(!o&&!r);return e.createElement("g",{role:b?"listbox":void 0,"aria-multiselectable":!(!b||"isolate"!==s&&(void 0!==s||null==a))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"}},void 0!==l&&""!==l&&"vertical"===d&&e.createElement("text",{className:"legend-title",y:16,x:c/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)"},l),m)}function Ee(e){return"string"==typeof e?{type:e}:e}function Oe({orient:t,config:n,values:o,scale:i,size:a,length:s}){const l=function(e){var t,n,o,r,i;return{type:e.type,bins:null!==(t=e.bins)&&void 0!==t?t:20,fill:null!==(n=e.fill)&&void 0!==n?n:"#4e79a7",fillOpacity:null!==(o=e.fillOpacity)&&void 0!==o?o:.5,stroke:null!==(r=e.stroke)&&void 0!==r?r:"none",strokeWidth:null!==(i=e.strokeWidth)&&void 0!==i?i:1}}(n),c="top"===t||"bottom"===t,u=r(()=>{if(0===o.length)return null;const n=i.domain(),r=a-8;if("boxplot"===l.type){const n=function(e){const t=[...e].sort((e,t)=>e-t),n=t.length;if(0===n)return null;const o=t[Math.floor(.25*n)],r=t[Math.floor(.5*n)],i=t[Math.floor(.75*n)],a=i-o;return{q1:o,median:r,q3:i,whiskerLow:Math.max(t[0],o-1.5*a),whiskerHigh:Math.min(t[n-1],i+1.5*a)}}(o);if(!n)return null;const{q1:a,median:s,q3:u,whiskerLow:d,whiskerHigh:p}=n,h=Math.min(.5*r,20),y=(r-h)/2+4;if(c){const n=i(a),o=i(u),r=i(s),c=i(d),g=i(p),f="top"===t?-1:1,m=0;return e.createElement("g",{"data-testid":"marginal-boxplot-"+t},e.createElement("line",{x1:c,y1:m+f*(y+h/2),x2:g,y2:m+f*(y+h/2),stroke:l.fill,strokeWidth:l.strokeWidth}),e.createElement("line",{x1:c,y1:m+f*y,x2:c,y2:m+f*(y+h),stroke:l.fill,strokeWidth:l.strokeWidth}),e.createElement("line",{x1:g,y1:m+f*y,x2:g,y2:m+f*(y+h),stroke:l.fill,strokeWidth:l.strokeWidth}),e.createElement("rect",{x:Math.min(n,o),y:"top"===t?m-y-h:m+y,width:Math.abs(o-n),height:h,fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}),e.createElement("line",{x1:r,y1:"top"===t?m-y-h:m+y,x2:r,y2:"top"===t?m-y:m+y+h,stroke:l.fill,strokeWidth:2}))}{const n=i(a),o=i(u),r=i(s),c=i(d),g=i(p),f="left"===t?-1:1,m=0;return e.createElement("g",{"data-testid":"marginal-boxplot-"+t},e.createElement("line",{x1:m+f*(y+h/2),y1:c,x2:m+f*(y+h/2),y2:g,stroke:l.fill,strokeWidth:l.strokeWidth}),e.createElement("line",{x1:m+f*y,y1:c,x2:m+f*(y+h),y2:c,stroke:l.fill,strokeWidth:l.strokeWidth}),e.createElement("line",{x1:m+f*y,y1:g,x2:m+f*(y+h),y2:g,stroke:l.fill,strokeWidth:l.strokeWidth}),e.createElement("rect",{x:"left"===t?m-y-h:m+y,y:Math.min(n,o),width:h,height:Math.abs(o-n),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}),e.createElement("line",{x1:"left"===t?m-y-h:m+y,y1:r,x2:"left"===t?m-y:m+y+h,y2:r,stroke:l.fill,strokeWidth:2}))}}const u=E().domain(n).thresholds(l.bins)(o);if(0===u.length)return null;const d=Math.max(...u.map(e=>e.length));if(0===d)return null;if("histogram"===l.type)return e.createElement("g",{"data-testid":"marginal-histogram-"+t},u.map((n,o)=>{if(null==n.x0||null==n.x1)return null;const a=n.length/d*r;if(c){const r=i(n.x0),s=i(n.x1)-i(n.x0);return e.createElement("rect",{key:o,x:r,y:"top"===t?-4-a:4,width:Math.max(s,.5),height:a,fill:l.fill,fillOpacity:l.fillOpacity,stroke:l.stroke,strokeWidth:l.strokeWidth})}{const r=i(n.x0),s=i(n.x1)-i(n.x0);return e.createElement("rect",{key:o,x:"left"===t?-4-a:4,y:Math.min(r,r+s),width:a,height:Math.abs(s),fill:l.fill,fillOpacity:l.fillOpacity,stroke:l.stroke,strokeWidth:l.strokeWidth})}}));if("violin"===l.type){const n=r/2+4,o=[];for(const e of u){if(null==e.x0||null==e.x1)continue;const a=e.length/d*(r/2),s=i((e.x0+e.x1)/2);o.push(c?`${s},${"top"===t?-(n-a):n-a}`:`${"left"===t?-(n-a):n-a},${s}`)}for(let e=u.length-1;e>=0;e--){const a=u[e];if(null==a.x0||null==a.x1)continue;const s=a.length/d*(r/2),l=i((a.x0+a.x1)/2);o.push(c?`${l},${"top"===t?-(n+s):n+s}`:`${"left"===t?-(n+s):n+s},${l}`)}return e.createElement("g",{"data-testid":"marginal-violin-"+t},e.createElement("polygon",{points:o.join(" "),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}))}if("ridgeline"===l.type){const n=[];if(c){const e=0,o=null!=u[0].x0?i(u[0].x0):0;n.push(`M${o},${e}`);for(const e of u){if(null==e.x0||null==e.x1)continue;const o=e.length/d*r,a=i((e.x0+e.x1)/2);n.push(`L${a},${"top"===t?-o-4:o+4}`)}const a=null!=u[u.length-1].x1?i(u[u.length-1].x1):s;n.push(`L${a},${e}`),n.push("Z")}else{const e=0,o=null!=u[0].x0?i(u[0].x0):0;n.push(`M${e},${o}`);for(const e of u){if(null==e.x0||null==e.x1)continue;const o=e.length/d*r,a=i((e.x0+e.x1)/2);n.push(`L${"left"===t?-o-4:o+4},${a}`)}const a=null!=u[u.length-1].x1?i(u[u.length-1].x1):s;n.push(`L${e},${a}`),n.push("Z")}return e.createElement("g",{"data-testid":"marginal-ridgeline-"+t},e.createElement("path",{d:n.join(" "),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}))}return null},[o,i,l,a,s,t,c,4]);return u?e.createElement("g",{className:"marginal-"+t,"data-testid":"marginal-"+t},u):null}function Se(e,t=120,n=8){if(!e)return[];const o=Math.max(1,Math.floor(t/n)),r=e.split(/\s+/),i=[];let a="";for(const e of r)a&&a.length+1+e.length>o?(i.push(a),a=e):a=a?`${a} ${e}`:e;return a&&i.push(a),i}function Me(e,t,n,o){return"curly"===e?o?`M0,0 C${.6*n},0 ${.4*n},${t/2} ${n},${t/2} C${.4*n},${t/2} ${.6*n},${t} 0,${t}`:`M0,0 C0,${.6*n} ${t/2},${.4*n} ${t/2},${n} C${t/2},${.4*n} ${t},${.6*n} ${t},0`:o?`M0,0 L${n},0 L${n},${t} L0,${t}`:`M0,0 L0,${n} L${t},${n} L${t},0`}function Ce(t){const{x:n=0,y:o=0,dx:r,dy:i,nx:a,ny:s,note:l,connector:c,subject:u,type:d,color:p,className:h,disable:y,events:g={},"data-testid":f}=t,m=new Set(Array.isArray(y)?y:[]);let b=r||0,v=i||0;null!=a&&(b=a-n),null!=s&&(v=s-o);const x="string"==typeof d?d:"label";if("bracket"===x&&u&&0===b&&0===v)if(void 0!==u.width){b=u.width/2;const e=u.depth||30;v=e+(0>e?-5:5)}else if(void 0!==u.height){const e=u.depth||30;b=e+(0>e?-5:5),v=u.height/2}return e.createElement("g",Object.assign({className:("annotation "+(h||"")).trim(),transform:`translate(${n},${o})`,"data-testid":f},g),!m.has("connector")&&function(t,n,o,r,i,a){const s=[];let l=0,c=0;if("callout-circle"!==i&&"label"!==i||!(null==a?void 0:a.radius)){if("callout-rect"===i&&a){const e=a.width||0,o=a.height||0;if(e>0||o>0){const r=e/2,i=o/2,a=t-r,s=n-i;if(0!==a||0!==s){const t=Math.abs(a),n=Math.abs(s),u=e/2,d=o/2,p=t*d>n*u?u/t:d/n;l=r+a*p,c=i+s*p}}}else if("bracket"===i&&a){const e=a.width,t=a.height,n=a.depth||30;void 0!==e?(l=e/2,c=n):void 0!==t&&(l=n,c=t/2)}}else{const e=(a.radius||0)+(a.radiusPadding||0);if(e>0&&(0!==t||0!==n)){const o=Math.atan2(n,t);l=Math.cos(o)*e,c=Math.sin(o)*e}}if(Math.sqrt(Math.pow(t-l,2)+Math.pow(n-c,2))>.5&&(s.push(e.createElement("line",{key:"connector-line",x1:l,y1:c,x2:t,y2:n,stroke:r||"var(--semiotic-text-secondary, currentColor)"})),"arrow"===(null==o?void 0:o.end))){const o=10,i=16/180*Math.PI,a=Math.atan2(n-c,t-l);s.push(e.createElement("path",{key:"connector-arrow",d:`M${l},${c}L${l+o*Math.cos(a+i)},${c+o*Math.sin(a+i)}L${l+o*Math.cos(a-i)},${c+o*Math.sin(a-i)}Z`,fill:r||"var(--semiotic-text-secondary, currentColor)",stroke:"none"}))}return e.createElement("g",{className:"annotation-connector"},s)}(b,v,c,p,x,u),!m.has("subject")&&function(t,n,o,r,i){var a;const s=[];switch(t){case"callout-circle":{const t=((null==n?void 0:n.radius)||0)+((null==n?void 0:n.radiusPadding)||0);t>0&&s.push(e.createElement("circle",{key:"subject-circle",r:t,fill:"none",stroke:o||"var(--semiotic-text-secondary, currentColor)"}));break}case"callout-rect":{const t=(null==n?void 0:n.width)||0,r=(null==n?void 0:n.height)||0;(t>0||r>0)&&s.push(e.createElement("rect",{key:"subject-rect",width:t,height:r,fill:"none",stroke:o||"var(--semiotic-text-secondary, currentColor)"}));break}case"callout-custom":(null==n?void 0:n.custom)&&s.push(...Array.isArray(n.custom)?n.custom:[n.custom]);break;case"xy-threshold":{const t=r||0,a=i||0;if(void 0!==(null==n?void 0:n.x)){const r=(n.x||0)-t;s.push(e.createElement("line",{key:"threshold-line",x1:r,y1:(n.y1||0)-a,x2:r,y2:(n.y2||0)-a,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"}))}else if(void 0!==(null==n?void 0:n.y)){const r=(n.y||0)-a;s.push(e.createElement("line",{key:"threshold-line",x1:(n.x1||0)-t,y1:r,x2:(n.x2||0)-t,y2:r,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"}))}else void 0!==(null==n?void 0:n.x1)||void 0!==(null==n?void 0:n.x2)?s.push(e.createElement("line",{key:"threshold-line",x1:(n.x1||0)-t,y1:0,x2:(n.x2||0)-t,y2:0,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"})):void 0===(null==n?void 0:n.y1)&&void 0===(null==n?void 0:n.y2)||s.push(e.createElement("line",{key:"threshold-line",x1:0,y1:(n.y1||0)-a,x2:0,y2:(n.y2||0)-a,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"}));break}case"bracket":{const t=null!==(a=null==n?void 0:n.width)&&void 0!==a?a:null==n?void 0:n.height;void 0!==t&&s.push(e.createElement("path",{key:"bracket-path",d:Me((null==n?void 0:n.type)||"curly",t,(null==n?void 0:n.depth)||30,void 0===(null==n?void 0:n.width)),fill:"none",stroke:o||"var(--semiotic-text-secondary, currentColor)"}));break}}return e.createElement("g",{className:"annotation-subject"},s)}(x,u,p,n,o),!m.has("note")&&function(t,n,o,r){if(!t)return e.createElement("g",{className:"annotation-note"});const{label:i,title:a,orientation:s,align:l,wrap:c=120,noWrap:u}=t;if(!i&&!a)return e.createElement("g",{className:"annotation-note"});let d=s;d||(d=Math.abs(n)>Math.abs(o)?"leftRight":"topBottom");let p=l;p&&"dynamic"!==p||(p="topBottom"===d?0>n?"right":"left":0>o?"bottom":"top");let h="start";"topBottom"===d?"right"===p?h="end":"middle"===p&&(h="middle"):h=0>n?"end":"start";const y=16,g=a?u?[a]:Se(a,c):[],f=i?u?[i]:Se(i,c):[],m="leftRight"===d?"end"===h?-4:4:0;let b=0;const v=[],x=r||"var(--semiotic-text, #333)";g.length>0&&(v.push(e.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:x,textAnchor:h,fontWeight:"bold"},g.map((t,n)=>e.createElement("tspan",{key:n,x:m,dy:0===n?0:y},t)))),b=g.length*y),f.length>0&&v.push(e.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:x,textAnchor:h,y:b},f.map((t,n)=>e.createElement("tspan",{key:n,x:m,dy:0===n?0:y},t))));let k=null;if((a||i)&&(0!==n||0!==o))if("topBottom"===d){const t=Math.min(c,120);let n=0,o=t;"end"===h?(n=-t,o=0):"middle"===h&&(n=-t/2,o=t/2),k=e.createElement("line",{className:"note-line",x1:n,x2:o,y1:0,y2:0,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}else{const t=(g.length+f.length)*y+(f.length>0?y:0);let n=0,o=t;"bottom"===p?(n=-t,o=0):"middle"===p&&(n=-t/2,o=t/2),k=e.createElement("line",{className:"note-line",x1:0,x2:0,y1:n,y2:o,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}const w=Math.max(0,g.length+f.length-1)*y;let A=0;return"topBottom"===d?A=0>o?-(w+2):18:"leftRight"===d&&(A="middle"===p?-(w+y+(f.length>0&&g.length>0?2:0))/2+8:"bottom"===p||0>o?-(w+2):18),e.createElement("g",{className:"annotation-note",transform:`translate(${n},${o})`},e.createElement("g",{className:"annotation-note-content",transform:0!==A?`translate(0,${A})`:void 0},v),k)}(l,b,v,p))}function $e(t){var n,o;const{noteData:r}=t,{screenCoordinates:i}=r,a="string"==typeof r.type?r.type:"label",s=r.eventListeners||r.events||{};if(r.coordinates&&i){const t=r.nx||i[0][0]+(null!==(n=r.dx)&&void 0!==n?n:0),s=r.ny||i[0][1]+(null!==(o=r.dy)&&void 0!==o?o:0),l=i.map((n,o)=>{const i=Object.assign({},r,{note:0===o?r.note:{label:""},x:n[0],y:n[1],nx:t,ny:s});return e.createElement(Ce,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+o},i,{type:a}))});return e.createElement("g",null,l)}const l=r.note||{title:"none",label:r.label};return e.createElement(Ce,Object.assign({"data-testid":"semiotic-annotation",key:`${l.label}-${l.title}-${r.i}`,events:s},r,{type:a}))}function ze(e,t){var n,o,r;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.x)&&void 0!==o?o:null===(r=t.scales)||void 0===r?void 0:r.time;return i?null!=e.x?i(e.x):t.xAccessor&&null!=e[t.xAccessor]?i(e[t.xAccessor]):null:null}function Le(e,t){var n,o,r;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.y)&&void 0!==o?o:null===(r=t.scales)||void 0===r?void 0:r.value;return i?null!=e.y?i(e.y):t.yAccessor&&null!=e[t.yAccessor]?i(e[t.yAccessor]):null:null}function Pe(e,t,n){var o,r,i,a;const s=e.anchor||"fixed";if("latest"===s){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let r=n.pointNodes.length-1;r>=0;r--){const i=n.pointNodes[r];if(i.pointId===e.pointId){const e={x:i.x,y:i.y};return null===(o=n.stickyPositionCache)||void 0===o||o.set(t,e),e}}const i=function(e){var t,n,o,r,i,a;const s=e.data;if(!s||0===s.length)return null;const l=s[s.length-1],c=null!==(n=null===(t=e.scales)||void 0===t?void 0:t.x)&&void 0!==n?n:null===(o=e.scales)||void 0===o?void 0:o.time,u=null!==(i=null===(r=e.scales)||void 0===r?void 0:r.y)&&void 0!==i?i:null===(a=e.scales)||void 0===a?void 0:a.value;if(!c||!u)return null;const d=l[e.xAccessor||"x"],p=l[e.yAccessor||"y"];return null==d||null==p?null:{x:c(d),y:u(p)}}(n);return i&&(null===(r=n.stickyPositionCache)||void 0===r||r.set(t,i)),i}let l=null,c=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(l=t.x,c=t.y)}if(null!=l&&null!=c||(l=ze(e,n),c=Le(e,n)),null!=l&&null!=c)return null===(i=n.stickyPositionCache)||void 0===i||i.set(t,{x:l,y:c}),{x:l,y:c};if("sticky"===s){const e=null===(a=n.stickyPositionCache)||void 0===a?void 0:a.get(t);if(e)return e}return null}function Ie(e,t,n,o=50){return!(-o>e||e>(n.width||0)+o||-o>t||t>(n.height||0)+o)}const Be={linear:D,monotoneX:N,monotoneY:B,step:I,stepAfter:P,stepBefore:L,basis:z,cardinal:$,catmullRom:C};let Ne={positions:new Map};const De=new Set;function Te(){for(const e of De)e()}function Re(e,t){const n=Ne.positions.get(e);if(null==n?void 0:n.locked)return;if(!n||n.sourceId!==t)return;const o=new Map(Ne.positions);o.delete(e),Ne={positions:o},Te()}function We(e,t){const n=Ne.positions.get(e);if(!(null==n?void 0:n.locked))return;if(t&&n.sourceId!==t)return;const o=new Map(Ne.positions);o.delete(e),Ne={positions:o},Te()}function Fe(){return Ne}function _e(e){return De.add(e),()=>De.delete(e)}const He={positions:new Map};function qe(){return()=>{}}function Ge(){return He}function Ve(e){if(e)return"dashed"===e?"6,4":"dotted"===e?"2,4":e}function Ue(e,t,n){if("left"===e||"right"===e){const o="left"===e?n:0,r="left"===e?-1:1,i=Math.ceil(t/8);let a="M0,"+o;for(let e=0;i>e;e++){const n=8*(e+1);a+=`L${Math.min(8*e+4,t)},${o+4*r}`,a+=`L${Math.min(n,t)},${o}`}return a}{const o="bottom"===e?0:t,r="bottom"===e?1:-1,i=Math.ceil(n/8);let a=`M${o},0`;for(let e=0;i>e;e++){const t=8*(e+1);a+=`L${o+4*r},${Math.min(8*e+4,n)}`,a+=`L${o},${Math.min(t,n)}`}return a}}function Ze(e,t,n){return e instanceof Date?`${e.toLocaleString("en",{month:"short"})} ${e.getDate()}`:"number"==typeof e?Math.round(100*e)/100+"":e+""}function Ye(e,t){if(2>=e.length)return e;const n=[e[0]];for(let o=1;e.length-1>o;o++)t>Math.abs(e[o].pixel-n[n.length-1].pixel)||n.push(e[o]);const o=e[e.length-1];return t>Math.abs(o.pixel-n[n.length-1].pixel)?n[n.length-1]=o:n.push(o),n}function Xe(n){var a,s;const{width:l,height:c,totalWidth:u,totalHeight:d,margin:p,scales:h,showAxes:y,axes:g,xLabel:f,yLabel:m,yLabelRight:b,xFormat:v,yFormat:x,showGrid:k,title:w,legend:A,legendHoverBehavior:j,legendClickBehavior:E,legendHighlightedCategory:O,legendIsolatedCategories:C,legendPosition:$="right",foregroundGraphics:z,marginalGraphics:L,xValues:P,yValues:I,annotations:B,svgAnnotationRules:N,xAccessor:T,yAccessor:R,annotationData:F,pointNodes:_,curve:H,underlayRendered:q,linkedCrosshairName:G,linkedCrosshairSourceId:V,children:U}=n,Z=r(()=>{var e;if(!y||!h)return[];const t=null==g?void 0:g.find(e=>"bottom"===e.orient),n=(null==t?void 0:t.tickFormat)||v||Ze,o=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5,r=h.x.ticks(Math.min(o,Math.max(2,Math.floor(l/70)))),i=r.map(e=>e.valueOf()),a=r.map((e,t)=>({value:e,pixel:h.x(e),label:n(e,t,i)})),s=a.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0),c=(null==t?void 0:t.autoRotate)?Math.max(20,Math.min(s+8,55)):Math.max(55,s+8);let u=Ye(a,c);if(u.length>1&&(u=u.filter((e,t)=>0===t||e.label+""!=u[t-1].label+"")),(null==t?void 0:t.includeMax)&&u.length>0){const e=h.x.domain()[1],t=h.x(e),o=u[u.length-1].pixel;if(Math.abs(t-o)>1){const r=n(e,u.length,i);c>t-o&&u.length>1&&(u=u.slice(0,-1)),u.push({value:e,pixel:t,label:r})}}return u},[y,h,g,v,l]),Y=r(()=>{var e;if(!y||!h)return[];const t=null==g?void 0:g.find(e=>"left"===e.orient),n=(null==t?void 0:t.tickFormat)||x||Ze,o=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;let r=Ye(h.y.ticks(Math.min(o,Math.max(2,Math.floor(c/30)))).map(e=>({value:e,pixel:h.y(e),label:n(e)})),22);if(r.length>1&&(r=r.filter((e,t)=>0===t||e.label+""!=r[t-1].label+"")),(null==t?void 0:t.includeMax)&&r.length>0){const e=h.y.domain()[1],t=h.y(e),o=r[r.length-1].pixel;if(Math.abs(t-o)>1){const i=n(e);22>Math.abs(t-o)&&r.length>1&&(r=r.slice(0,-1)),r.push({value:e,pixel:t,label:i})}}return r},[y,h,g,x,c]),X=r(()=>{var e;if(!y||!h)return[];const t=null==g?void 0:g.find(e=>"right"===e.orient);if(!t)return[];const n=t.tickFormat||x||Ze,o=null!==(e=t.ticks)&&void 0!==e?e:5;return Ye(h.y.ticks(Math.min(o,Math.max(2,Math.floor(c/30)))).map(e=>({value:e,pixel:h.y(e),label:n(e)})),22)},[y,h,g,x,c]),K=t(new Map),J=t(null!==(a=null==B?void 0:B.length)&&void 0!==a?a:0),Q=null!==(s=null==B?void 0:B.length)&&void 0!==s?s:0;J.current!==Q&&(J.current=Q,K.current=new Map);const ee=r(()=>{if(!B||0===B.length)return null;const t=function(t,n,o){var r,i,a,s,l,c,u,d,p,h,y,g,f,m,b,v,x,k,w,A,j,E,O,C,$,z,L,P,I,B,N,T,R,F,_,H,q,G,V,U,Z,Y,X,K,J,Q,ee,te;switch(t.type){case"label":{const r=Pe(t,n,o);if(!r)return null;const{x:i,y:a}=r;return Ie(i,a,o)?e.createElement($e,{key:"ann-"+n,noteData:{x:i,y:a,dx:t.dx||30,dy:t.dy||-30,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"label",connector:t.connector||{end:"arrow"},color:t.color}}):null}case"callout":{const r=Pe(t,n,o);if(!r)return null;const{x:i,y:a}=r;return Ie(i,a,o)?e.createElement($e,{key:"ann-"+n,noteData:{x:i,y:a,dx:t.dx||30,dy:t.dy||-30,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"callout-circle",subject:{radius:t.radius||12},connector:t.connector||{end:"arrow"},color:t.color}}):null}case"x-threshold":{const r=ze(t,o);if(null==r)return null;const i=t.color||"#f97316",a=t.labelPosition||"top";let s;return s="bottom"===a?(o.height||0)-4:"center"===a?(o.height||0)/2:12,e.createElement("g",{key:"ann-"+n},e.createElement("line",{x1:r,y1:0,x2:r,y2:o.height||0,stroke:i,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.createElement("text",{x:r+4,y:s,fill:i,fontSize:12,fontWeight:"bold"},t.label))}case"y-threshold":{const r=Le(t,o);if(null==r)return null;const i=t.color||"#f97316",a=t.labelPosition||"right";let s,l;return"left"===a?(s=4,l="start"):"center"===a?(s=(o.width||0)/2,l="middle"):(s=(o.width||0)-4,l="end"),e.createElement("g",{key:"ann-"+n},e.createElement("line",{x1:0,y1:r,x2:o.width||0,y2:r,stroke:i,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.createElement("text",{x:s,y:r-4,textAnchor:l,fill:i,fontSize:12,fontWeight:"bold"},t.label))}case"enclose":{const r=(t.coordinates||[]).map(e=>({x:ze(Object.assign(Object.assign({},e),{type:"point"}),o),y:Le(Object.assign(Object.assign({},e),{type:"point"}),o),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>r.length)return null;const i=S(r),a=t.padding||10;return e.createElement("g",{key:"ann-"+n},e.createElement("circle",{cx:i.x,cy:i.y,r:i.r+a,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&e.createElement("text",{x:i.x,y:i.y-i.r-a-4,textAnchor:"middle",fill:t.color||"var(--semiotic-text-secondary, #666)",fontSize:12},t.label))}case"rect-enclose":{const r=(t.coordinates||[]).map(e=>({x:ze(Object.assign(Object.assign({},e),{type:"point"}),o),y:Le(Object.assign(Object.assign({},e),{type:"point"}),o)})).filter(e=>null!=e.x&&null!=e.y);if(2>r.length)return null;const i=t.padding||10,a=r.map(e=>e.x),s=r.map(e=>e.y),l=Math.min(...a)-i,c=Math.max(...a)+i,u=Math.min(...s)-i,d=Math.max(...s)+i;return e.createElement("g",{key:"ann-"+n},e.createElement("rect",{x:l,y:u,width:c-l,height:d-u,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&e.createElement("text",{x:(l+c)/2,y:u-4,textAnchor:"middle",fill:t.color||"var(--semiotic-text-secondary, #666)",fontSize:12},t.label))}case"highlight":{const r=o.data||[],i="function"==typeof t.filter?r.filter(t.filter):t.field&&null!=t.value?r.filter(e=>e[t.field]===t.value):[],a={stroke:t.color||"#f97316",strokeWidth:2,fill:"none"};return e.createElement("g",{key:"ann-"+n},i.map((n,r)=>{const i=ze(n,o),s=Le(n,o);if(null==i||null==s)return null;const l="function"==typeof t.r?t.r(n):t.r||6,c="function"==typeof t.style?t.style(n):t.style||a;return e.createElement("circle",Object.assign({key:"hl-"+r,cx:i,cy:s,r:l},c))}))}case"bracket":{const r=ze(t,o),i=Le(t,o);return e.createElement($e,{key:"ann-"+n,noteData:{x:null!=r?r:0,y:null!=i?i:0,dx:t.dx||0,dy:t.dy||0,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"bracket",subject:{type:t.bracketType||"curly",width:t.width,height:t.height,depth:t.depth||30},color:t.color}})}case"trend":{const d=o.data||[];if(2>d.length)return null;const p=o.xAccessor||"x",h=o.yAccessor||"y",y=d.map(e=>[e[p],e[h]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>y.length)return null;const g=null!==(i=null===(r=o.scales)||void 0===r?void 0:r.x)&&void 0!==i?i:null===(a=o.scales)||void 0===a?void 0:a.time,f=null!==(l=null===(s=o.scales)||void 0===s?void 0:s.y)&&void 0!==l?l:null===(c=o.scales)||void 0===c?void 0:c.value;if(!g||!f)return null;const m=t.method||"linear";let b;b="loess"===m?function(e,t=.3){const n=e.length;if(2>n)return e.slice();const o=e.slice().sort((e,t)=>e[0]-t[0]),r=o.map(e=>e[0]),i=o.map(e=>e[1]),a=Math.max(2,Math.ceil(t*n)),s=[];for(let e=0;n>e;e++){const t=r[e],o=r.map(e=>Math.abs(e-t)),l=o.slice().sort((e,t)=>e-t)[Math.min(a-1,n-1)]||1,c=[];for(let e=0;n>e;e++){const t=0===l?0:o[e]/l;c[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,d=0,p=0,h=0,y=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(u+=t,d+=t*r[e],p+=t*i[e],h+=t*r[e]*r[e],y+=t*r[e]*i[e])}if(0===u){s.push([t,i[e]]);continue}const g=u*h-d*d;if(1e-12>Math.abs(g))s.push([t,p/u]);else{const e=(u*y-d*p)/g;s.push([t,(p-e*d)/u+e*t])}}return s}(y,null!==(u=t.bandwidth)&&void 0!==u?u:.3):("polynomial"===m?W.polynomial(y,{order:t.order||2}):W.linear(y)).points;const v=b.map(([e,t])=>`${g(e)},${f(t)}`).join(" "),x=t.color||"#6366f1";return e.createElement("g",{key:"ann-"+n},e.createElement("polyline",{points:v,fill:"none",stroke:x,strokeWidth:t.strokeWidth||2,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.createElement("text",{x:g(b[b.length-1][0])+4,y:f(b[b.length-1][1])-4,fill:x,fontSize:11},t.label))}case"band":{const r=null!==(p=null===(d=o.scales)||void 0===d?void 0:d.y)&&void 0!==p?p:null===(h=o.scales)||void 0===h?void 0:h.value,i=null!==(y=null==r?void 0:r(t.y0))&&void 0!==y?y:0,a=null!==(g=null==r?void 0:r(t.y1))&&void 0!==g?g:o.height||0;return e.createElement("g",{key:"ann-"+n},e.createElement("rect",{x:0,y:Math.min(i,a),width:o.width||0,height:Math.abs(a-i),fill:t.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:t.fillOpacity||.1}),t.label&&e.createElement("text",{x:(o.width||0)-4,y:Math.min(i,a)-4,textAnchor:"end",fill:t.color||"var(--semiotic-primary, #6366f1)",fontSize:11},t.label))}case"envelope":{const r=o.data||[];if(2>r.length)return null;const i=o.xAccessor||"x",a=null!==(m=null===(f=o.scales)||void 0===f?void 0:f.x)&&void 0!==m?m:null===(b=o.scales)||void 0===b?void 0:b.time,s=null!==(x=null===(v=o.scales)||void 0===v?void 0:v.y)&&void 0!==x?x:null===(k=o.scales)||void 0===k?void 0:k.value;if(!a||!s)return null;const l=t.upperAccessor||"upperBounds",c=t.lowerAccessor||"lowerBounds",u=t.filter,d=r.filter(e=>null!=e[l]&&null!=e[c]&&!(u&&!u(e))).sort((e,t)=>e[i]-t[i]);if(2>d.length)return null;const p=Be[o.curve||"linear"]||D,h=M().x(e=>a(e[i])).y0(e=>s(e[c])).y1(e=>s(e[l])).curve(p)(d);if(!h)return null;const y=t.fill||"#6366f1";return e.createElement("g",{key:"ann-"+n},e.createElement("path",{d:h,fill:y,fillOpacity:null!==(w=t.fillOpacity)&&void 0!==w?w:.15,stroke:"none"}),t.label&&d.length>0&&e.createElement("text",{x:a(d[d.length-1][i])+4,y:s(d[d.length-1][l])-4,fill:y,fontSize:11},t.label))}case"anomaly-band":{const r=o.data||[];if(2>r.length)return null;const i=o.yAccessor||"y",a=null!==(j=null===(A=o.scales)||void 0===A?void 0:A.x)&&void 0!==j?j:null===(E=o.scales)||void 0===E?void 0:E.time,s=null!==(C=null===(O=o.scales)||void 0===O?void 0:O.y)&&void 0!==C?C:null===($=o.scales)||void 0===$?void 0:$.value;if(!a||!s)return null;const l=r.map(e=>e[i]).filter(e=>null!=e&&isFinite(e));if(2>l.length)return null;const c=l.reduce((e,t)=>e+t,0)/l.length,u=l.reduce((e,t)=>e+Math.pow(t-c,2),0)/l.length,d=Math.sqrt(u),p=null!==(z=t.threshold)&&void 0!==z?z:2,h=c-p*d,y=!1!==t.showBand,g=t.fill||"#6366f1",f=null!==(L=t.fillOpacity)&&void 0!==L?L:.1,m=t.anomalyColor||"#ef4444",b=null!==(P=t.anomalyRadius)&&void 0!==P?P:6,v=s(c+p*d),x=s(h),k=r.filter(e=>{const t=e[i];return null!=t&&Math.abs(t-c)>p*d});return e.createElement("g",{key:"ann-"+n},y&&e.createElement("rect",{x:0,y:Math.min(v,x),width:o.width||0,height:Math.abs(x-v),fill:g,fillOpacity:f}),k.map((t,n)=>{const r=ze(t,o),i=Le(t,o);return null==r||null==i?null:e.createElement("circle",{key:"anomaly-"+n,cx:r,cy:i,r:b,fill:m,fillOpacity:.7,stroke:m,strokeWidth:1.5})}),t.label&&e.createElement("text",{x:(o.width||0)-4,y:Math.min(v,x)-4,textAnchor:"end",fill:g,fontSize:11},t.label))}case"forecast":{const r=o.data||[];if(3>r.length)return null;const i=o.xAccessor||"x",a=o.yAccessor||"y",s=null!==(B=null===(I=o.scales)||void 0===I?void 0:I.x)&&void 0!==B?B:null===(N=o.scales)||void 0===N?void 0:N.time,l=null!==(R=null===(T=o.scales)||void 0===T?void 0:T.y)&&void 0!==R?R:null===(F=o.scales)||void 0===F?void 0:F.value;if(!s||!l)return null;const c=r.map(e=>[e[i],e[a]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>c.length)return null;let u;if("polynomial"===(t.method||"linear")){const e=W.polynomial(c,{order:t.order||2}).equation;u=t=>e.reduce((e,n,o)=>e+n*Math.pow(t,o),0)}else{const e=c.length;let t=0,n=0,o=0,r=0;for(const[e,i]of c)t+=e,n+=i,o+=e*e,r+=e*i;const i=e*o-t*t;if(1e-12>Math.abs(i))return null;const a=(e*r-t*n)/i,s=(n-a*t)/e;u=e=>s+a*e}const d=c.length,p=c.map(([e,t])=>t-u(e)).reduce((e,t)=>e+t*t,0),h=Math.sqrt(p/Math.max(d-2,1)),y=c.reduce((e,t)=>e+t[0],0)/d,g=c.reduce((e,t)=>e+Math.pow(t[0]-y,2),0),f=null!==(_=t.confidence)&&void 0!==_?_:.95,m=.99>f?.95>f?.9>f?1:1.645:1.96:2.576,b=null!==(H=t.steps)&&void 0!==H?H:5,v=c[d-1][0],x=(v-c[0][0])/Math.max(d-1,1),k=[];for(let e=1;b>=e;e++)k.push(v+e*x);const w=[];for(const e of k){const t=u(e),n=h*Math.sqrt(1+1/d+(g>0?Math.pow(e-y,2)/g:0))*m;w.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const A=`M${w.map(e=>`${s(e.x)},${l(e.yUpper)}`).join(" L")} L${w.slice().reverse().map(e=>`${s(e.x)},${l(e.yLower)}`).join(" L")} Z`,j=w.map(e=>`${s(e.x)},${l(e.yCenter)}`).join(" "),E=`${s(v)},${l(u(v))}`,O=t.strokeColor||"#6366f1";return e.createElement("g",{key:"ann-"+n},e.createElement("path",{d:A,fill:t.fill||"#6366f1",fillOpacity:null!==(q=t.fillOpacity)&&void 0!==q?q:.15,stroke:"none"}),e.createElement("polyline",{points:`${E} ${j}`,fill:"none",stroke:O,strokeWidth:null!==(G=t.strokeWidth)&&void 0!==G?G:2,strokeDasharray:null!==(V=t.strokeDasharray)&&void 0!==V?V:"6,3"}),t.label&&w.length>0&&e.createElement("text",{x:s(w[w.length-1].x)+4,y:l(w[w.length-1].yCenter)-4,fill:O,fontSize:11},t.label))}case"widget":{let r=null,i=null;if(null!=t.px&&null!=t.py)r=t.px,i=t.py;else{const e=Pe(t,n,o);if(!e)return null;r=e.x,i=e.y}if(null==r||null==i)return null;if(!Ie(r,i,o))return null;const a=null!==(U=t.dx)&&void 0!==U?U:0,s=null!==(Z=t.dy)&&void 0!==Z?Z:0,l=null!==(Y=t.width)&&void 0!==Y?Y:32,c=null!==(X=t.height)&&void 0!==X?X:32,u=null!==(K=t.content)&&void 0!==K?K:e.createElement("span",{style:{fontSize:18,cursor:"default"},title:t.label||"Info"},"ℹ️");return e.createElement("foreignObject",{key:"ann-"+n,x:r+a-l/2,y:i+s-c/2,width:l,height:c,style:{overflow:"visible",pointerEvents:"auto"}},e.createElement("div",{style:{width:l,height:c,display:"flex",alignItems:"center",justifyContent:"center"}},u))}case"text":{const r=Pe(t,n,o);if(!r)return null;const{x:i,y:a}=r;return e.createElement("text",{key:"ann-text-"+n,x:i+(t.dx||0),y:a+(t.dy||0),fill:t.color||"var(--semiotic-text, #333)",fontSize:t.fontSize||11,dominantBaseline:"middle",style:{fontFamily:"inherit"}},t.label)}case"category-highlight":{const r=t.category;if(null==r)return null;const i=null===(J=o.scales)||void 0===J?void 0:J.o,a=null===(Q=o.scales)||void 0===Q?void 0:Q.x,s=null===(ee=o.scales)||void 0===ee?void 0:ee.y,l=(null==i?void 0:i.bandwidth)?i:(null==a?void 0:a.bandwidth)?a:(null==s?void 0:s.bandwidth)?s:null;if(!l)return null;const c=l(r);if(null==c)return null;const u=l.bandwidth(),d=t.color||"var(--semiotic-primary, #4589ff)",p=null!==(te=t.opacity)&&void 0!==te?te:.15,h=t.label;return(o.projection?"vertical"===o.projection:l===a)?e.createElement("g",{key:"ann-"+n},e.createElement("rect",{x:c,y:0,width:u,height:o.height||0,fill:d,fillOpacity:p}),h&&e.createElement("text",{x:c+u/2,y:12,textAnchor:"middle",fill:d,fontSize:12,fontWeight:"bold"},h)):e.createElement("g",{key:"ann-"+n},e.createElement("rect",{x:0,y:c,width:o.width||0,height:u,fill:d,fillOpacity:p}),h&&e.createElement("text",{x:12,y:c+u/2,dominantBaseline:"middle",fill:d,fontSize:12,fontWeight:"bold"},h))}default:return null}},n={scales:h?{x:h.x,y:h.y,time:h.x,value:h.y}:null,timeAxis:"x",xAccessor:T,yAccessor:R,width:l,height:c,data:F,frameType:"xy",pointNodes:_,curve:H,stickyPositionCache:K.current};return B.map((e,o)=>{if(N){const r=N(e,o,n);return null!=r?r:t(e,o,n)}return t(e,o,n)}).filter(Boolean)},[B,N,l,c,T,R,F,h,_,H]),te=function(e){var t;const n=i(e?_e:qe,e?Fe:Ge,e?Fe:Ge);return e&&null!==(t=n.positions.get(e))&&void 0!==t?t:null}(G);return o(()=>{if(!(null==te?void 0:te.locked)||!G)return;const e=e=>{"Escape"===e.key&&We(G)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[null==te?void 0:te.locked,G]),y||w||A||z||L||ee&&ee.length>0||k||U||te?e.createElement("svg",{role:"img",width:u,height:d,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"}},e.createElement("title",null,"string"==typeof w?w:"XY Chart"),e.createElement("desc",null,"string"==typeof w?w+" — XY data visualization":"XY data visualization"),e.createElement("g",{transform:`translate(${p.left},${p.top})`},k&&h&&!q&&(()=>{var t,n;const o=Ve(null===(t=null==g?void 0:g.find(e=>"bottom"===e.orient))||void 0===t?void 0:t.gridStyle),r=Ve(null===(n=null==g?void 0:g.find(e=>"left"===e.orient))||void 0===n?void 0:n.gridStyle);return e.createElement("g",{className:"stream-grid"},Z.map((t,n)=>e.createElement("line",{key:"xgrid-"+n,x1:t.pixel,y1:0,x2:t.pixel,y2:c,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o})),Y.map((t,n)=>e.createElement("line",{key:"ygrid-"+n,x1:0,y1:t.pixel,x2:l,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r})))})(),y&&h&&(()=>{const t=null==g?void 0:g.find(e=>"left"===e.orient),n=null==g?void 0:g.find(e=>"bottom"===e.orient),o=!t||!1!==t.baseline,r=!n||!1!==n.baseline,i=(null==t?void 0:t.jaggedBase)||!1,a=(null==n?void 0:n.jaggedBase)||!1,s=null==n?void 0:n.landmarkTicks,u=null==t?void 0:t.landmarkTicks,d="var(--semiotic-border, #ccc)",h="var(--semiotic-text-secondary, var(--semiotic-text, #666))",y="var(--semiotic-text, #333)",v=!!(null==n?void 0:n.autoRotate)&&Z.length>1&&(()=>{const e=l/Math.max(Z.length-1,1);return Z.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:60),0)+8>e})();return e.createElement("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"}},!q&&r&&!a&&e.createElement("line",{x1:0,y1:c,x2:l,y2:c,stroke:d,strokeWidth:1}),!q&&a&&e.createElement("path",{d:Ue("bottom",l,c),fill:"none",stroke:d,strokeWidth:1}),Z.map((t,n)=>{const o=!!s&&("function"==typeof s?s(t.value,n):fe(t.value,n>0?Z[n-1].value:void 0));return e.createElement("g",{key:"xtick-"+n,transform:`translate(${t.pixel},${c})`},e.createElement("line",{y2:5,stroke:d,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?e.createElement("text",{y:v?10:18,textAnchor:v?"end":"middle",fontSize:o?11:10,fontWeight:o?600:400,fill:h,style:{userSelect:"none"},transform:v?"rotate(-45)":void 0},t.label):e.createElement("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"}},e.createElement("div",{style:{textAlign:"center",fontSize:10,userSelect:"none"}},t.label)))}),f&&e.createElement("text",{x:l/2,y:c+40,textAnchor:"middle",fontSize:12,fill:y,style:{userSelect:"none"}},f),!q&&o&&!i&&e.createElement("line",{x1:0,y1:0,x2:0,y2:c,stroke:d,strokeWidth:1}),!q&&i&&e.createElement("path",{d:Ue("left",l,c),fill:"none",stroke:d,strokeWidth:1}),Y.map((t,n)=>{const o=!!u&&("function"==typeof u?u(t.value,n):fe(t.value,n>0?Y[n-1].value:void 0));return e.createElement("g",{key:"ytick-"+n,transform:`translate(0,${t.pixel})`},e.createElement("line",{x2:-5,stroke:d,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?e.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:o?11:10,fontWeight:o?600:400,fill:h,style:{userSelect:"none"}},t.label):e.createElement("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"}},e.createElement("div",{style:{textAlign:"right",fontSize:10,userSelect:"none"}},t.label)))}),(()=>{const n=(null==t?void 0:t.label)||m;return n?e.createElement("text",{x:15-p.left,y:c/2,textAnchor:"middle",fontSize:12,fill:y,transform:`rotate(-90, ${15-p.left}, ${c/2})`,style:{userSelect:"none"}},n):null})(),(()=>{const t=null==g?void 0:g.find(e=>"right"===e.orient);if(!t||0===X.length)return null;const n=t.landmarkTicks,o=t.label||b;return e.createElement(e.Fragment,null,!1!==t.baseline&&e.createElement("line",{x1:l,y1:0,x2:l,y2:c,stroke:d,strokeWidth:1}),X.map((t,o)=>{const r=!!n&&("function"==typeof n?n(t.value,o):fe(t.value,o>0?X[o-1].value:void 0));return e.createElement("g",{key:"ytick-r-"+o,transform:`translate(${l},${t.pixel})`},e.createElement("line",{x2:5,stroke:d,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?e.createElement("text",{x:8,textAnchor:"start",dominantBaseline:"middle",fontSize:r?11:10,fontWeight:r?600:400,fill:h,style:{userSelect:"none"}},t.label):e.createElement("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"}},e.createElement("div",{style:{textAlign:"left",fontSize:10,userSelect:"none"}},t.label)))}),o&&e.createElement("text",{x:l+p.right-15,y:c/2,textAnchor:"middle",fontSize:12,fill:y,transform:`rotate(90, ${l+p.right-15}, ${c/2})`,style:{userSelect:"none"}},o))})())})(),ee,L&&h&&P&&I&&e.createElement(e.Fragment,null,L.top&&e.createElement("g",{transform:"translate(0, 0)"},e.createElement(Oe,{orient:"top",config:Ee(L.top),values:P,scale:h.x,size:p.top,length:l})),L.bottom&&e.createElement("g",{transform:`translate(0, ${c})`},e.createElement(Oe,{orient:"bottom",config:Ee(L.bottom),values:P,scale:h.x,size:p.bottom,length:l})),L.left&&e.createElement("g",{transform:"translate(0, 0)"},e.createElement(Oe,{orient:"left",config:Ee(L.left),values:I,scale:h.y,size:p.left,length:c})),L.right&&e.createElement("g",{transform:`translate(${l}, 0)`},e.createElement(Oe,{orient:"right",config:Ee(L.right),values:I,scale:h.y,size:p.right,length:c}))),z,te&&te.sourceId!==V&&(null==h?void 0:h.x)&&(()=>{const t=h.x(te.xValue);if(null==t||0>t||t>l)return null;const n=te.locked;return e.createElement("line",{x1:t,y1:0,x2:t,y2:c,stroke:n?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:n?1.5:1,strokeDasharray:n?"6,3":"4,4",pointerEvents:"none"})})(),U),w&&e.createElement("text",{x:u/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof w?w:null),function(t){const{legend:n,totalWidth:o,totalHeight:r,margin:i,legendPosition:a="right",title:s,legendHoverBehavior:l,legendClickBehavior:c,legendHighlightedCategory:u,legendIsolatedCategories:d,legendInteraction:p}=t;if(!n)return null;const h="top"===a||"bottom"===a;let y,g;return"left"===a?(y=4,g=i.top):"top"===a?(y=0,g=s?32:8):"bottom"===a?(y=0,g=r-i.bottom+50):(y=o-i.right+10,g=i.top),e.createElement("g",{transform:`translate(${y}, ${g})`},"object"==typeof(f=n)&&null!==f&&"gradient"in f?e.createElement(Ae,{config:n.gradient,orientation:h?"horizontal":"vertical",width:h?o:100}):function(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}(n)?e.createElement(je,{legendGroups:n.legendGroups,title:"",width:h?o:100,orientation:h?"horizontal":"vertical",customHoverBehavior:l,customClickBehavior:c,highlightedCategory:u,isolatedCategories:d,legendInteraction:p}):n);var f}({legend:A,totalWidth:u,totalHeight:d,margin:p,legendPosition:$,title:w,legendHoverBehavior:j,legendClickBehavior:E,legendHighlightedCategory:O,legendIsolatedCategories:C})):null}function Ke(e,t="#4e79a7"){return e&&"string"==typeof e?e:t}const Je="undefined"==typeof window||"undefined"==typeof document,Qe=e.createContext(null),et={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function tt(e,t){if(!e||0===e.length)return t+", empty";const n={};for(const t of e)n[t.type]=(n[t.type]||0)+1;const o=[],r={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks",wedge:"wedges",arc:"arcs",geoarea:"regions"},i=["point","line","area","rect","heatcell","circle","candlestick","wedge","arc","geoarea"],a=Object.keys(n).sort((e,t)=>{const n=i.indexOf(e),o=i.indexOf(t);return(-1===n?999:n)-(-1===o?999:o)});for(const e of a)o.push(`${n[e]} ${r[e]||e}`);return`${t}, ${o.join(", ")}`}const nt=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},ot={position:"absolute",top:0,left:0,right:0,zIndex:5,padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-text, #333)",background:"var(--semiotic-bg, #fff)",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},rt={marginBottom:8,paddingRight:28,color:"var(--semiotic-text-secondary, #666)",fontSize:12,letterSpacing:"0.01em"},it={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-border, #e0e0e0)",background:"var(--semiotic-bg, #fff)",cursor:"pointer",color:"var(--semiotic-text-secondary, #666)",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},at={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},st={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-border, #e0e0e0)",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-text-secondary, #666)"},lt={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},ct={textAlign:"left",fontSize:11,color:"var(--semiotic-text-secondary, #999)",marginBottom:4,fontStyle:"italic"};function ut({scene:t,chartType:n,tableId:o,chartTitle:r}){var i;const[a,s]=e.useState(!1),l=e.useContext(Qe),c=null!==(i=null==l?void 0:l.visible)&&void 0!==i&&i,u=a||c,d=e.useRef(null),p=r?"Data summary for "+r:o?`Data summary for ${n} ${o}`:"Data summary for "+n,h=e.useCallback(()=>{a||c||s(!0)},[a,c]),y=e.useCallback(e=>{var t;c||(null===(t=d.current)||void 0===t?void 0:t.contains(e.relatedTarget))||s(!1)},[c]);if(!t||0===t.length)return o?e.createElement("span",{id:o,tabIndex:-1,style:et}):null;if(!u)return e.createElement("div",{id:o,tabIndex:-1,onFocus:h,style:et,role:"region","aria-label":p},e.createElement("button",{type:"button",onClick:()=>s(!0)},"View data summary (",t.length," elements)"));const g=function(e){var t,n,o,r,i,a,s,l,c,u,d,p,h,y,g,f,m,b,v,x,k,w,A,j,E;const O=[];if(!Array.isArray(e))return O;for(const S of e)if(S&&"object"==typeof S)try{switch(S.type){case"point":O.push({label:"Point",values:{x:S.x,y:S.y}});break;case"line":{const e=S.path,t=Array.isArray(S.datum)?S.datum:[];if(!Array.isArray(e))break;for(let n=0;e.length>n&&t.length>n;n++){const t=e[n];Array.isArray(t)&&O.push({label:"Line point",values:{x:t[0],y:t[1]}})}break}case"area":{const e=S.topPath,t=Array.isArray(S.datum)?S.datum:[];if(!Array.isArray(e))break;for(let n=0;e.length>n&&t.length>n;n++){const t=e[n];Array.isArray(t)&&O.push({label:"Area point",values:{x:t[0],y:t[1]}})}break}case"rect":{const e=null!=S.datum&&"object"==typeof S.datum?S.datum:{},i=null!==(n=null!==(t=e.category)&&void 0!==t?t:S.group)&&void 0!==n?n:"",a=null!==(r=null!==(o=e.value)&&void 0!==o?o:e.__aggregateValue)&&void 0!==r?r:e.total;O.push({label:"Bar",values:{category:i,value:null!=a?a:""}});break}case"heatcell":O.push({label:"Cell",values:{x:S.x,y:S.y,value:S.value}});break;case"wedge":O.push({label:"Wedge",values:{category:null!==(l=null!==(a=null===(i=S.datum)||void 0===i?void 0:i.category)&&void 0!==a?a:null===(s=S.datum)||void 0===s?void 0:s.label)&&void 0!==l?l:"",value:null!==(u=null===(c=S.datum)||void 0===c?void 0:c.value)&&void 0!==u?u:""}});break;case"circle":O.push({label:"Node",values:{id:null!==(p=null===(d=S.datum)||void 0===d?void 0:d.id)&&void 0!==p?p:"",x:null!==(h=S.cx)&&void 0!==h?h:S.x,y:null!==(y=S.cy)&&void 0!==y?y:S.y}});break;case"arc":O.push({label:"Arc",values:{id:null!==(f=null===(g=S.datum)||void 0===g?void 0:g.id)&&void 0!==f?f:"",x:null!==(m=S.cx)&&void 0!==m?m:S.x,y:null!==(b=S.cy)&&void 0!==b?b:S.y}});break;case"candlestick":O.push({label:"Candlestick",values:{x:S.x,open:S.open,high:S.high,low:S.low,close:S.close}});break;case"geoarea":O.push({label:"Region",values:{name:null!==(A=null!==(k=null===(x=null===(v=S.datum)||void 0===v?void 0:v.properties)||void 0===x?void 0:x.name)&&void 0!==k?k:null===(w=S.datum)||void 0===w?void 0:w.name)&&void 0!==A?A:"",value:null!==(E=null===(j=S.datum)||void 0===j?void 0:j.value)&&void 0!==E?E:""}})}}catch(e){}return O}(t),f=function(e){if(!e||0===e.length)return[];const t=new Set;for(const n of e)if(n&&n.values)for(const e of Object.keys(n.values))t.add(e);const n=[];for(const o of t){const t=[],r=new Set;for(const n of e){if(!n||!n.values)continue;const e=n.values[o];null!=e&&""!==e&&("number"==typeof e&&!Number.isNaN(e)&&Number.isFinite(e)?t.push(e):"number"==typeof e||"object"!=typeof e&&"function"!=typeof e&&r.add(e+""))}if(t.length>0){let e=t[0],r=t[0],i=0;for(const n of t)e>n&&(e=n),n>r&&(r=n),i+=n;n.push({name:o,count:t.length,numeric:!0,min:e,max:r,mean:i/t.length})}else if(r.size>0){const e=Array.from(r);n.push({name:o,count:e.length,numeric:!1,uniqueValues:e.slice(0,5)})}}return n}(g),m=function(e,t){const n=[e+" data points."];for(const e of t)if(e.numeric)n.push(`${e.name}: ${nt(e.min)} to ${nt(e.max)}, mean ${nt(e.mean)}.`);else{const t=e.uniqueValues,o=t.length>3?`${t.slice(0,3).join(", ")}… (${e.count} unique)`:t.join(", ");n.push(`${e.name}: ${o}.`)}return n.join(" ")}(g.length,f),b=g.slice(0,5),v=new Set;for(const e of b)for(const t of Object.keys(e.values))v.add(t);const x=Array.from(v);return e.createElement("div",{ref:d,id:o,tabIndex:-1,onBlur:y,style:ot,role:"region","aria-label":p},e.createElement("button",{type:"button",onClick:()=>{c&&l&&l.setVisible(!1),s(!1)},"aria-label":"Close data summary",style:it},"×"),e.createElement("div",{role:"note",style:rt},m),e.createElement("table",{role:"table","aria-label":"Sample data for "+n,style:at},e.createElement("caption",{style:ct},"First ",b.length," of ",g.length," data points"),e.createElement("thead",null,e.createElement("tr",null,e.createElement("th",{style:st},"type"),x.map(t=>e.createElement("th",{key:t,style:st},t)))),e.createElement("tbody",null,b.map((t,n)=>e.createElement("tr",{key:n},e.createElement("td",{style:lt},t.label),x.map(n=>{return e.createElement("td",{key:n,style:lt},null==(o=t.values[n])||""===o?"—":"number"==typeof o?Number.isNaN(o)?"—":nt(o):"boolean"==typeof o?o?"true":"false":"object"==typeof o?"—":o+"");var o}))))))}function dt({summary:t}){return t?e.createElement("div",{role:"note",style:et},t):null}function pt({tableId:t}){return e.createElement("a",{href:"#"+t,style:et,onClick:e=>{e.preventDefault();const n=document.getElementById(t);n&&requestAnimationFrame(()=>n.focus())},onFocus:e=>{Object.assign(e.currentTarget.style,{position:"absolute",width:"auto",height:"auto",overflow:"visible",clip:"auto",whiteSpace:"normal",padding:"4px 8px",background:"var(--semiotic-bg, #fff)",color:"var(--semiotic-text, #000)",border:"2px solid var(--semiotic-focus, #005fcc)",borderRadius:"4px",zIndex:"10",fontSize:"12px",top:"4px",left:"4px"})},onBlur:e=>{const t=e.currentTarget;t.removeAttribute("style"),Object.assign(t.style,et)}},"Skip to data table")}function ht({hoverPoint:t}){let n="";if(t){const e=t.data||t;n="object"==typeof e?"Focused on data point: "+Object.entries(e).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Focused on data point: "+e}return e.createElement("div",{"aria-live":"polite","aria-atomic":"true",style:et},n)}const yt="var(--semiotic-focus, #005fcc)";function gt({active:t,hoverPoint:n,margin:o,size:r,shape:i="circle",width:a,height:s}){if(!t||!n)return null;const l=n.x+o.left,c=n.y+o.top;let u;if("rect"===i&&null!=a&&null!=s){const t=Math.max(a,4),n=Math.max(s,4);u=e.createElement("rect",{x:l-t/2-3,y:c-n/2-3,width:t+6,height:n+6,rx:3,fill:"none",stroke:yt,strokeWidth:2,strokeDasharray:"4,2"})}else u=e.createElement("circle","wedge"===i?{cx:l,cy:c,r:12,fill:"none",stroke:yt,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:l,cy:c,r:8,fill:"none",stroke:yt,strokeWidth:2,strokeDasharray:"4,2"});return e.createElement("svg",{style:{position:"absolute",left:0,top:0,width:r[0],height:r[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true"},u)}function ft({x:t,y:n,containerWidth:o,containerHeight:r,margin:i,children:a,className:s="stream-frame-tooltip",zIndex:l=1}){const c=e.useRef(null),[u,d]=e.useState(null);e.useLayoutEffect(()=>{const e=c.current;if(!e)return;const t=e.getBoundingClientRect();d(e=>e&&e.width===t.width&&e.height===t.height?e:{width:t.width,height:t.height})},[a,s,o,r]);let p;return p=u?`translate(${u.width+12>o-t?"calc(-100% - 12px)":"12px"}, ${u.height+12>r-n?"calc(-100% - 4px)":"4px"})`:`translate(${t>.7*o?"calc(-100% - 12px)":"12px"}, ${.3*r>n?"4px":"calc(-100% - 4px)"})`,e.createElement("div",{ref:c,className:s,style:{position:"absolute",left:i.left+t,top:i.top+n,transform:p,pointerEvents:"none",zIndex:l,width:"max-content"}},a)}function mt(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function bt(e,t,n=.6){var o,r,i,a,s;if(!mt(t))return;const l=null!==(o=t._pulseGlowRadius)&&void 0!==o?o:4,c=t.r+l*t._pulseIntensity,u=null!==(i=null!==(r=t.cx)&&void 0!==r?r:t.x)&&void 0!==i?i:0,d=null!==(s=null!==(a=t.cy)&&void 0!==a?a:t.y)&&void 0!==s?s:0;e.beginPath(),e.arc(u,d,c,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*n,e.stroke()}function vt(e,t,n,o=.35){mt(t)&&(e.globalAlpha=t._pulseIntensity*o,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",n?e.fill(n):e.fill())}function xt(e){switch(e){case"monotoneX":return N;case"monotoneY":return B;case"cardinal":return $;case"catmullRom":return C;case"step":return I;case"stepBefore":return L;case"stepAfter":return P;case"basis":return z;case"natural":return R;default:return null}}function kt(e,t,n){let o=n;for(const n of t)"lesser"===n.thresholdType?n.value>e&&(o=n.color):e>n.value&&(o=n.color);return o}function wt(e,t,n,o,r,i){if(2>t.length)return;const a=[0];for(let e=1;t.length>e;e++){const n=t[e][0]-t[e-1][0],o=t[e][1]-t[e-1][1];a.push(a[e-1]+Math.sqrt(n*n+o*o))}const s=a[a.length-1];if(0===s)return;const l=Math.min(.2*s,40);e.strokeStyle=n,e.lineWidth=o,e.lineCap=i;for(let n=0;t.length-1>n;n++){const o=(a[n]+a[n+1])/2;let i=r;l>o&&(i*=o/l),l>s-o&&(i*=(s-o)/l),e.globalAlpha=Math.max(0,i),e.beginPath(),e.moveTo(t[n][0],t[n][1]),e.lineTo(t[n+1][0],t[n+1][1]),e.stroke()}}function At(e){return e.k}function jt(e){return[e.x,e.y]}function Et(e){return function(){return e}}function Ot([e,t,n]){const o=1<<n;return[e-Math.floor(e/o)*o,t-Math.floor(t/o)*o,n]}function St(e,t,n,o){const r=e.getContext("2d");if(!r)return null;const i=t[0]*o,a=t[1]*o,s=t[0]+"px",l=t[1]+"px";return e.style.width!==s&&(e.style.width=s),e.style.height!==l&&(e.style.height=l),e.width===i&&e.height===a||(e.width=i,e.height=a),r.setTransform(o,0,0,o,0,0),r.translate(n.left,n.top),r}function Mt(){return"undefined"!=typeof window&&window.devicePixelRatio||1}function Ct(e,t,n,o,r){return"function"==typeof e?e(t,n,o,r):e.replace("{z}",t+"").replace("{x}",n+"").replace("{y}",o+"").replace("{r}",r>1?"@2x":"")}class $t{constructor(e=256){this.cache=new Map,this.limit=e}get(e){const t=this.cache.get(e);return t&&(t.lastUsed=performance.now()),t}set(e,t){this.cache.set(e,t),this.cache.size>this.limit&&this.evict()}evict(){for(;this.cache.size>this.limit;){let e,t=1/0;for(const[n,o]of this.cache)t>o.lastUsed&&(t=o.lastUsed,e=n);if(!e)break;{const t=this.cache.get(e);t&&(t.img.onload=null,t.img.onerror=null,t.img.src=""),this.cache.delete(e)}}}clear(){for(const e of this.cache.values())e.img.onload=null,e.img.onerror=null,e.img.src="";this.cache.clear()}}class zt{constructor(e){this.capacity=e,this.particles=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,lineIndex:0,active:!1,x:0,y:0}}spawn(e){for(let t=0;this.capacity>t;t++){const n=this.particles[t];if(!n.active)return n.active=!0,n.t=0,n.offset=.6*(Math.random()-.5),n.lineIndex=e,n.x=0,n.y=0,n}return null}step(e,t,n,o){for(let r=0;this.capacity>r;r++){const i=this.particles[r];if(!i.active)continue;const a=n[i.lineIndex];if(!a||2>a.length){i.active=!1;continue}if(i.t+=e*t,i.t>=1){i.active=!1;continue}const s=Lt(a),l=Pt(a,i.t*s),c=(o[i.lineIndex]||2)/2;i.x=l.x+l.nx*i.offset*c*2,i.y=l.y+l.ny*i.offset*c*2}}countForLine(e){let t=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].lineIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1}}function Lt(e){let t=0;for(let n=1;e.length>n;n++){const o=e[n][0]-e[n-1][0],r=e[n][1]-e[n-1][1];t+=Math.sqrt(o*o+r*r)}return t}function Pt(e,t){let n=0;for(let o=1;e.length>o;o++){const r=e[o][0]-e[o-1][0],i=e[o][1]-e[o-1][1],a=Math.sqrt(r*r+i*i);if(n+a>=t||o===e.length-1){const s=a>0?(t-n)/a:0,l=a>.001?a:1;return{x:e[o-1][0]+r*s,y:e[o-1][1]+i*s,nx:-i/l,ny:r/l}}n+=a}const o=e[e.length-1];return{x:o[0],y:o[1],nx:0,ny:0}}function It(n){const o=a(null),c=Bt(n);return[function({children:t}){const i=r(()=>Bt(n),[]);return e.createElement(o.Provider,{value:i,children:t})},e=>{var n;const r=null!==(n=s(o))&&void 0!==n?n:c,a=t(e);a.current=e;const u=l(()=>a.current(r.getState()),[r]),d=l(()=>a.current(r.getState()),[r]);return i(r.subscribe,u,d)}]}function Bt(e){const t=new EventTarget;let n=e(function(e){n=Object.assign(Object.assign({},n),e(n)),t.dispatchEvent(new CustomEvent("update"))});return{getState:()=>n,subscribe:function(e){return t.addEventListener("update",e),()=>t.removeEventListener("update",e)}}}const Nt={mode:"light",colors:{primary:"#00a2ce",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",background:"transparent",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},Dt={mode:"dark",colors:{primary:"#4fc3f7",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",background:"#1a1a2e",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},Tt={mode:"light",colors:{primary:"#0000cc",categorical:["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],sequential:"blues",diverging:"RdBu",background:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1},typography:{fontFamily:"system-ui, sans-serif",titleSize:18,labelSize:14,tickSize:12},tooltip:{background:"#000000",text:"#ffffff",borderRadius:"4px",fontSize:"14px",shadow:"0 2px 8px rgba(0, 0, 0, 0.3)"},borderRadius:"4px"},[Rt,Wt]=It(e=>({theme:Nt,setTheme(t){e(e=>{if("light"===t)return{theme:Nt};if("dark"===t)return{theme:Dt};if("high-contrast"===t)return{theme:Tt};if(t.mode&&"auto"!==t.mode){const e="dark"===t.mode?Dt:Nt;return{theme:Object.assign(Object.assign(Object.assign({},e),t),{colors:Object.assign(Object.assign({},e.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.typography),t.typography||{})})}}return{theme:Object.assign(Object.assign(Object.assign({},e.theme),t),{colors:Object.assign(Object.assign({},e.theme.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.theme.typography),t.typography||{})})}})}})),Ft={top:10,right:10,bottom:10,left:10},_t={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"},Ht={width:28,height:28,border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,background:"rgba(255,255,255,0.9)",color:"#333",fontSize:16,fontWeight:600,lineHeight:1,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:0,boxShadow:"0 1px 3px rgba(0,0,0,0.1)"};function qt({data:t}){if(!t)return null;if(t.properties)return e.createElement("div",{className:"semiotic-tooltip",style:_t},e.createElement("div",{style:{fontWeight:600}},t.properties.name||t.properties.NAME||t.properties.id||"Feature"));const n=Object.entries(t).slice(0,3);return e.createElement("div",{className:"semiotic-tooltip",style:_t},n.map(([t,n])=>e.createElement("div",{key:t},e.createElement("span",{style:{opacity:.7}},t,": "),e.createElement("span",{style:{fontWeight:600}},n+""))))}const Gt=c(function(i,a){var s,c,d,p,h,y,g,f,m,b;const{projection:v,projectionExtent:x,fitPadding:k,projectionTransform:w,areas:A,points:j,lines:E,xAccessor:O,yAccessor:S,lineDataAccessor:M,pointIdAccessor:C,lineType:$="geo",flowStyle:z="basic",graticule:L,zoomable:P,zoomExtent:I,onZoom:B,dragRotate:N,showParticles:D,particleStyle:R,tileURL:W,tileAttribution:q,tileCacheSize:G,size:V,width:U,height:Z,responsiveWidth:Y,responsiveHeight:X,margin:K,className:J,background:Q,areaStyle:ee,pointStyle:te,lineStyle:ne,colorScheme:oe,enableHover:re=!0,hoverAnnotation:ie,tooltipContent:ae,customClickBehavior:se,customHoverBehavior:le,annotations:ce,decay:ue,pulse:de,transition:pe,staleness:ye,backgroundGraphics:ge,foregroundGraphics:fe,title:be,legend:ve,legendPosition:xe,legendHoverBehavior:ke,legendClickBehavior:we,legendHighlightedCategory:Ae,legendIsolatedCategories:je,showAxes:Ee,accessibleTable:Oe=!0,description:Se,summary:Me}=i,Ce=function(){const[e,t]=n(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return o(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");return t(e.matches),function(e,t){return"function"==typeof e.addEventListener?(e.addEventListener("change",t),()=>e.removeEventListener("change",t)):(e.addListener(t),()=>e.removeListener(t))}(e,e=>t(e.matches))},[]),e}(),$e=t(Ce);$e.current=Ce;const ze="semiotic-table-"+e.useId(),Le=V||[U||600,Z||400],[Pe,Ie]=function(e,r,i){const a=t(null),[s,l]=n(null);return o(()=>{if(!r&&!i)return;const e=a.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;l(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return t.observe(e),()=>t.disconnect()},[r,i]),[a,[r&&s?s.w:e[0],i&&s?s.h:e[1]]]}(Le,Y,X),Be=r(()=>Object.assign(Object.assign({},Ft),K),[K]),Ne=Ie[0]-Be.left-Be.right,De=Ie[1]-Be.top-Be.bottom,Te="function"==typeof fe?fe({size:Ie,margin:Be}):fe,Re="function"==typeof ge?ge({size:Ie,margin:Be}):ge,We=r(()=>null!=N?N:"orthographic"===("string"==typeof v?v:"object"==typeof v&&"type"in v?v.type:null),[N,v]),Fe=r(()=>({projection:v,projectionExtent:x,fitPadding:k,xAccessor:O,yAccessor:S,lineDataAccessor:M,lineType:$,flowStyle:z,areaStyle:ee,pointStyle:te,lineStyle:ne,colorScheme:oe,graticule:L,projectionTransform:w,decay:ue,pulse:de,transition:pe,annotations:ce,pointIdAccessor:C}),[v,x,k,O,S,M,$,z,ee,te,ne,oe,L,w,ue,de,pe,ce,C]),_e=t(null);_e.current||(_e.current=new he(Fe));const He=t(null),qe=t(null),Ge=t(null),Ve=t(null),Ue=t(null);W&&!Ue.current&&(Ue.current=new $t(G||256));const Ze=t(0),Ye=t(!0),Qe=Wt(e=>e.theme),et=t(ce),nt=t(()=>{}),ot=t(null),rt=t(F),it=t(!1),at=t(null),st=t(null),lt=t(null),ct=t(null),yt=t(0);if(D&&!ct.current){const e=null!==(s=null==R?void 0:R.maxPerLine)&&void 0!==s?s:30;ct.current=new zt(50*e)}const mt=t(null),Lt=t(null),[Pt,It]=n(null),[Bt,Nt]=n(0),[Dt,Tt]=n(!1),Rt=l(()=>{Ze.current||(Ze.current=requestAnimationFrame(()=>nt.current()))},[]);o(()=>{Ye.current=!0,Rt()},[Qe,Rt]),o(()=>{var e;null===(e=_e.current)||void 0===e||e.updateConfig(Fe),Ye.current=!0,Rt()},[Fe,Rt]),o(()=>{const e=_e.current;e&&(A&&e.setAreas(A),j&&e.setPoints(j),E&&e.setLines(E),Ye.current=!0,Rt())},[A,j,E,Rt]);const _t=l(e=>{var t;null===(t=_e.current)||void 0===t||t.pushPoint(e),Ye.current=!0,Rt()},[Rt]),Gt=l(e=>{var t;null===(t=_e.current)||void 0===t||t.pushMany(e),Ye.current=!0,Rt()},[Rt]),Vt=l(()=>{var e;null===(e=_e.current)||void 0===e||e.clear(),Ye.current=!0,Rt()},[Rt]);u(a,()=>({push:_t,pushMany:Gt,clear:Vt,getProjection:()=>{var e,t,n;return null!==(n=null===(t=null===(e=_e.current)||void 0===e?void 0:e.scales)||void 0===t?void 0:t.projection)&&void 0!==n?n:null},getGeoPath:()=>{var e,t,n;return null!==(n=null===(t=null===(e=_e.current)||void 0===e?void 0:e.scales)||void 0===t?void 0:t.geoPath)&&void 0!==n?n:null},getCartogramLayout:()=>{var e,t;return null!==(t=null===(e=_e.current)||void 0===e?void 0:e.cartogramLayout)&&void 0!==t?t:null},getZoom:()=>rt.current.k,resetZoom:()=>{const e=at.current;e&&ot.current&&H(e).call(ot.current.transform,F)},getData:()=>{const e=_e.current;return e?e.scene.filter(e=>"point"===e.type).map(e=>e.datum).filter(Boolean):[]}}),[_t,Gt,Vt]);const Ut=t(()=>{});o(()=>{Ut.current=e=>{if(!re)return;const t=_e.current;if(!t||!t.scene.length)return;const n=e.currentTarget.getBoundingClientRect(),o=e.clientX-n.left-Be.left,r=e.clientY-n.top-Be.top;if(0>o||o>Ne||0>r||r>De)return mt.current=null,Lt.current=null,It(null),null==le||le(null),void Rt();Ve.current||(Ve.current="undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(1,1):document.createElement("canvas"));const i=Ve.current.getContext("2d");if(!i)return;const a=me(t.scene,o,r,30,i);if(a){const e=a.node,t=e.datum,n=(null==t?void 0:t.properties)?t:(null==t?void 0:t.data)||t;let i,s;"point"===e.type?(i=e.x,s=e.y):"geoarea"===e.type?(i=e.centroid[0],s=e.centroid[1]):(i=o,s=r);const l=Object.assign(Object.assign(Object.assign({},n),(null==n?void 0:n.properties)||{}),{data:n,x:i,y:s,time:0});mt.current=l,Lt.current=e,It(l),null==le||le({type:e.type,data:n,x:i,y:s}),Rt()}else mt.current&&(mt.current=null,Lt.current=null,It(null),null==le||le(null),Rt())}},[re,Ne,De,Be,le,Rt]);const Zt=l(()=>{mt.current=null,Lt.current=null,It(null),null==le||le(null),Rt()},[le,Rt]),Yt=l(e=>{if(!se)return;const t=_e.current;if(!t||!t.scene.length)return;const n=e.currentTarget.getBoundingClientRect(),o=e.clientX-n.left-Be.left,r=e.clientY-n.top-Be.top;Ve.current||(Ve.current="undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(1,1):document.createElement("canvas"));const i=Ve.current.getContext("2d");if(!i)return;const a=me(t.scene,o,r,30,i);if(a){const e=a.node.datum;se({type:a.node.type,data:(null==e?void 0:e.properties)?e:(null==e?void 0:e.data)||e,x:o,y:r})}},[se,Be]),Xt=t(-1),Kt=t(null),Jt=l(e=>{const t=_e.current;if(!t||0===t.scene.length)return;const n=function(e){const t=[];for(const n of e)"point"===n.type&&null!=n.x?t.push({x:n.x,y:n.y,datum:n.datum,shape:"circle"}):"geoarea"===n.type&&n.centroid&&t.push({x:n.centroid[0],y:n.centroid[1],datum:n.datum,shape:"circle"});return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.scene);if(0===n.length)return;const o=Xt.current,r=function(e,t,n){switch(e){case"ArrowRight":case"ArrowDown":return n-1>t?t+1:t;case"ArrowLeft":case"ArrowUp":return t>0?t-1:t;case"PageDown":return Math.min(t+Math.max(1,Math.floor(.1*n)),n-1);case"PageUp":return Math.max(t-Math.max(1,Math.floor(.1*n)),0);case"Home":return 0;case"End":return n-1;case"Escape":return-1;default:return null}}(e.key,0>o?-1:o,n.length);if(null===r)return;if(e.preventDefault(),0>r)return Xt.current=-1,Kt.current=null,mt.current=null,Lt.current=null,It(null),null==le||le(null),void Rt();const i=0>o?0:r;Xt.current=i;const a=n[i];Kt.current={shape:a.shape,w:a.w,h:a.h};const s=function(e){const t=e.datum||{};return Object.assign(Object.assign({},"object"!=typeof t||null===t||Array.isArray(t)?{}:t),{data:t,x:e.x,y:e.y,time:e.x,value:e.y})}(a);mt.current=s,It(s);const l=a.datum;let c="point",u=l;l&&"object"==typeof l&&"geometry"in l&&(c="geoarea",l.properties&&"object"==typeof l.properties&&(u=Object.assign(Object.assign({},l),l.properties))),null==le||le({type:c,data:u,x:a.x,y:a.y}),Rt()},[le,Rt]),Qt=l(e=>{Xt.current=-1,Kt.current=null,Ut.current(e)},[]);nt.current=()=>{var e,t,n,o,r,i,a;Ze.current=0;const s=qe.current,l=_e.current;if(!s||!l)return;const c=performance.now();let u=!1;const d=lt.current;d&&(lt.current=null,l.applyRotation(d,{width:Ne,height:De}));const p=l.advanceTransition($e.current?c+1e6:c),h=!$e.current&&p;if(Ye.current&&!p){const e={width:Ne,height:De},t=We?l.getRotation():null;l.computeScene(e);const n=rt.current,o=1!==n.k||0!==n.x||0!==n.y;We&&t?o?(l.setRotation(t),l.applyZoomScale(n.k,e)):l.applyRotation(t,e):o&&l.applyZoomTransform(n,e),Ye.current=!1,s.setAttribute("aria-label",tt(l.scene,"Geographic chart"))}const y=Mt();if(W&&Ue.current){const t=He.current;if(t&&(null===(e=l.scales)||void 0===e?void 0:e.projection)){const e=St(t,Ie,Be,y);if(e){e.clearRect(-Be.left,-Be.top,Ie[0],Ie[1]),e.save(),e.beginPath(),e.rect(0,0,Ne,De),e.clip();const t=function(e,t){const{tileURL:n,projection:o,width:r,height:i,tileCache:a,onTileLoad:s}=t,l=o.scale(),c=o.translate(),u=2*l*Math.PI,d=function(){let e=0,t=0,n=960,o=500,r=!0,i=!0,a=256,s=At,l=jt,c=0;function u(){const u=+s.apply(this,arguments),d=l.apply(this,arguments),p=Math.log2(u/a),h=Math.round(Math.max(p+c,0)),y=Math.pow(2,p-h)*a,g=+d[0]-u/2,f=+d[1]-u/2,m=Math.max(r?0:-1/0,Math.floor((e-g)/y)),b=Math.min(r?1<<h:1/0,Math.ceil((n-g)/y)),v=Math.max(i?0:-1/0,Math.floor((t-f)/y)),x=Math.min(i?1<<h:1/0,Math.ceil((o-f)/y)),k=[];for(let e=v;x>e;++e)for(let t=m;b>t;++t)k.push([t,e,h]);return k.translate=[g/y,f/y],k.scale=y,k}return u.size=function(r){return arguments.length?(e=t=0,n=+r[0],o=+r[1],u):[n-e,o-t]},u.extent=function(r){return arguments.length?(e=+r[0][0],t=+r[0][1],n=+r[1][0],o=+r[1][1],u):[[e,t],[n,o]]},u.scale=function(e){return arguments.length?(s="function"==typeof e?e:Et(+e),u):s},u.translate=function(e){return arguments.length?(l="function"==typeof e?e:Et([+e[0],+e[1]]),u):l},u.zoomDelta=function(e){return arguments.length?(c=+e,u):c},u.tileSize=function(e){return arguments.length?(a=+e,u):a},u.clamp=function(e){return arguments.length?(r=i=!!e,u):r&&i},u.clampX=function(e){return arguments.length?(r=!!e,u):r},u.clampY=function(e){return arguments.length?(i=!!e,u):i},u}().size([r,i]).scale(u).translate(c).clamp(!0)(),p=Mt();let h=!0;for(const t of d){const[o,r,i]=Ot(t),l=`${i}/${o}/${r}`;let c=a.get(l);if(!c){const e=new Image;e.crossOrigin="anonymous";const t={img:e,loaded:!1,key:l,lastUsed:performance.now()};a.set(l,t),e.onload=()=>{t.loaded=!0,null==s||s()},e.onerror=()=>{t.loaded=!0},e.src=Ct(n,i,o,r,p),c=t}if(!c.loaded){h=!1;continue}const u=d.scale;e.drawImage(c.img,(t[0]+d.translate[0])*u-.5,(t[1]+d.translate[1])*u-.5,u+1,u+1)}return h}(e,{tileURL:W,projection:l.scales.projection,width:Ne,height:De,tileCache:Ue.current,onTileLoad:()=>Rt()});e.restore(),t||(u=!0)}}}const g=St(s,Ie,Be,y);if(!g)return;g.clearRect(-Be.left,-Be.top,Ie[0],Ie[1]),Q&&!W&&(g.fillStyle=Q,g.fillRect(0,0,Ne,De)),g.save(),g.beginPath(),g.rect(0,0,Ne,De),g.clip();const f=l.scene,m={height:De};if(function(e,t){var n,o,r;const i=t.filter(e=>"geoarea"===e.type);for(const t of i){if(!t.pathData)continue;const i=new Path2D(t.pathData),a=t.style.fill||"#e0e0e0";if("none"!==a&&(e.fillStyle=a,e.globalAlpha=(null!==(n=t._decayOpacity)&&void 0!==n?n:1)*(null!==(o=t.style.fillOpacity)&&void 0!==o?o:1),e.fill(i)),t.style.stroke&&"none"!==t.style.stroke){if(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||.5,e.globalAlpha=null!==(r=t._decayOpacity)&&void 0!==r?r:1,t.style.strokeDasharray){const n=t.style.strokeDasharray.split(",").map(Number);e.setLineDash(n)}else e.setLineDash([]);e.stroke(i)}vt(e,t,i),e.globalAlpha=1,e.setLineDash([])}}(g,f),((e,t,n,o)=>{var r,i;const a=t.filter(e=>"line"===e.type);for(const s of a){if(2>s.path.length)continue;const l=s.style.stroke||"#007bff",c=s.style.strokeWidth||2,u=s.colorThresholds,d=s.rawValues;if(e.setLineDash(s.style.strokeDasharray?s.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=s.style.opacity&&(e.globalAlpha=s.style.opacity),e.lineWidth=c,e.lineCap=s.style.strokeLinecap||"butt",s.style._edgeFade){const g=null!==(r=s.style.opacity)&&void 0!==r?r:1;wt(e,s.path,l,c,g,s.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const p=xt(s.curve),h=u&&u.length>0&&d&&d.length===s.path.length,y=s._decayOpacities;if(y&&y.length===s.path.length&&!h){e.strokeStyle=l;const f=null!==(i=s.style.opacity)&&void 0!==i?i:1;for(let m=0;s.path.length-1>m;m++)e.globalAlpha=.5*(y[m]+y[m+1])*f,e.beginPath(),e.moveTo(s.path[m][0],s.path[m][1]),e.lineTo(s.path[m+1][0],s.path[m+1][1]),e.stroke()}else if(h){let b=null,v=null,x=null,k=null,w=!1;function A(t,n,o){e.beginPath(),e.strokeStyle=t,e.moveTo(n,o),w=!0}function j(){w&&(e.stroke(),w=!1)}for(let E=0;s.path.length>E;E++){const[O,S]=s.path[E],M=d[E],C=kt(M,u,l);if(null!==b&&null!==k&&null!==x){if(C===k)e.lineTo(O,S);else{const $=[];for(const z of u){const L=z.value;(x>L||L>M)&&(L>x||M>L)||x===L||M===L||$.push({t:(L-x)/(M-x)})}$.sort((e,t)=>e.t-t.t);for(const P of $){const I=b+(O-b)*P.t,B=v+(S-v)*P.t,N=kt(x+(M-x)*Math.min(P.t+1e-4,1),u,l);e.lineTo(I,B),j(),A(N,I,B)}e.lineTo(O,S)}b=O,v=S,x=M,k=C}else A(C,O,S),b=O,v=S,x=M,k=C}j()}else{if(e.beginPath(),!s.strokeGradient||2>s.strokeGradient.colorStops.length||2>s.path.length)e.strokeStyle=l;else{const D=e.createLinearGradient(s.path[0][0],0,s.path[s.path.length-1][0],0);for(const R of s.strokeGradient.colorStops)D.addColorStop(Math.max(0,Math.min(1,R.offset)),R.color);e.strokeStyle=D}if(p)T().x(e=>e[0]).y(e=>e[1]).curve(p).context(e)(s.path);else{const[W,F]=s.path[0];e.moveTo(W,F);for(let _=1;s.path.length>_;_++)e.lineTo(s.path[_][0],s.path[_][1])}e.stroke()}if(s.style.fill&&s.style.fillOpacity&&s.style.fillOpacity>0){if(e.beginPath(),e.globalAlpha=s.style.fillOpacity,e.fillStyle=s.style.fill,p&&!h)T().x(e=>e[0]).y(e=>e[1]).curve(p).context(e)(s.path);else{const[q,G]=s.path[0];e.moveTo(q,G);for(let V=1;s.path.length>V;V++)e.lineTo(s.path[V][0],s.path[V][1])}const H=s.path[0][0];e.lineTo(s.path[s.path.length-1][0],o.height),e.lineTo(H,o.height),e.closePath(),e.fill()}e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}})(g,f,0,m),((e,t)=>{var n;const o=t.filter(e=>"point"===e.type);if(0!==o.length){e.save();try{for(const t of o){e.beginPath(),e.arc(t.x,t.y,t.r,0,2*Math.PI);const o=null!==(n=t.style.opacity)&&void 0!==n?n:t.style.fillOpacity;null!=o&&(e.globalAlpha=o),e.fillStyle=t.style.fill||"#4e79a7",e.fill(),t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),bt(e,t),e.globalAlpha=1}}finally{e.restore()}}})(g,f),D&&ct.current){const e=ct.current,a=f.filter(e=>"line"===e.type);if(a.length>0){const s=R||{},l=.3*(null!==(t=s.speedMultiplier)&&void 0!==t?t:1),d=null!==(n=s.maxPerLine)&&void 0!==n?n:30,p=null!==(o=s.spawnRate)&&void 0!==o?o:.15,h=null!==(r=s.radius)&&void 0!==r?r:2,y=null!==(i=s.opacity)&&void 0!==i?i:.7,f=c/1e3,m=yt.current>0?Math.min(f-yt.current,.1):.016;yt.current=f;const b=a.map(e=>e.path),v=a.map(e=>e.style.strokeWidth||2);for(let t=0;a.length>t;t++)Math.random()<p&&e.countForLine(t)<d&&e.spawn(t);e.step(m,l,b,v),g.globalAlpha=y;for(let t=0;e.particles.length>t;t++){const n=e.particles[t];if(!n.active)continue;const o=a[n.lineIndex],r="function"==typeof s.color?s.color(null==o?void 0:o.datum):"source"!==s.color&&s.color?s.color:(null==o?void 0:o.style.stroke)||"#fff";g.beginPath(),g.arc(n.x,n.y,h,0,2*Math.PI),g.fillStyle=r,g.fill()}g.globalAlpha=1,u=!0}}g.restore();const b=Ge.current;if(b){const e=St(b,Ie,Be,y);if(e){e.clearRect(-Be.left,-Be.top,Ie[0],Ie[1]);const t=Lt.current;if(t&&"geoarea"===t.type){const n=new Path2D(t.pathData);e.fillStyle="rgba(255, 255, 255, 0.3)",e.fill(n),e.strokeStyle="rgba(0, 0, 0, 0.5)",e.lineWidth=2,e.stroke(n)}if(t&&"point"===t.type){const n=t,o="object"==typeof ie?ie:void 0,r=(null==o?void 0:o.pointColor)||function(e){if(!e)return null;if("heatcell"===e.type)return e.fill||null;if("candlestick"===e.type)return e.isUp?e.upColor:e.downColor;const{style:t}=e;if(!t)return null;const n="string"==typeof t.fill?t.fill:null;return"line"===e.type||"area"===e.type?t.stroke||n||null:n||t.stroke||null}(t);e.beginPath(),e.arc(n.x,n.y,n.r+3,0,2*Math.PI),r?(e.save(),e.globalAlpha=.4,e.fillStyle=r,e.fill(),e.restore()):(e.fillStyle="rgba(255, 255, 255, 0.4)",e.fill()),e.strokeStyle=r||"rgba(0, 0, 0, 0.5)",e.lineWidth=2,e.stroke()}}}if(ye){const e=performance.now()-l.lastIngestTime>(null!==(a=ye.threshold)&&void 0!==a?a:5e3);e!==Dt&&Tt(e)}const v=ce!==et.current;v&&(et.current=ce),(Ye.current||v)&&Nt(e=>e+1),(h||l.hasActivePulses||u)&&(Ze.current=requestAnimationFrame(()=>nt.current()))},o(()=>(Rt(),()=>{var e;Ze.current&&(cancelAnimationFrame(Ze.current),Ze.current=0),null===(e=Ue.current)||void 0===e||e.clear()}),[Rt]),o(()=>{Ye.current=!0,Rt()},[Ne,De,Q,Rt]),function(e,t,n,r,i,a){o(()=>{if(!e)return;const o=setInterval(()=>{var o;const s=t.current;if(!s||0===s.lastIngestTime)return;const l="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(o=e.threshold)&&void 0!==o?o:5e3,u=l-s.lastIngestTime>c;u!==i&&(a(u),n.current=!0,r())},1e3);return()=>clearInterval(o)},[e,i,r])}(ye,_e,Ye,Rt,Dt,Tt),o(()=>{if("production"!==process.env.NODE_ENV&&W){const e="string"==typeof v?v:"object"==typeof v&&"type"in v?v.type:null;e&&"mercator"!==e&&console.warn(`[StreamGeoFrame] tileURL is set but projection is "${e}". Raster tiles use Web Mercator and will not align with other projections.`)}},[W,v]),o(()=>{const e=at.current;if(!P||!e)return ot.current&&e&&(H(e).on(".zoom",null),ot.current=null),void(e&&H(e).on("mousedown.rotate",null).on("touchstart.rotate",null));const[t,n]=I||[1,8],o={width:Ne,height:De};if(We){let r=rt.current.k;const i=e=>{var i;r=Math.max(t,Math.min(n,e)),rt.current=F.scale(r);const a=_e.current;a&&(a.applyZoomScale(r,o),Ye.current=!1,Rt(),null==B||B({projection:null===(i=a.scales)||void 0===i?void 0:i.projection,zoom:a.currentZoom}))};ot.current={scaleBy:(e,t)=>i(r*t),transform:(e,t)=>{var n;return i(null!==(n=null==t?void 0:t.k)&&void 0!==n?n:1)}};const a=e=>{e.preventDefault(),i(r*(0>e.deltaY?1.1:1/1.1))},s=e=>{const t=e.target;t&&(t.closest("button")||t.closest(".stream-geo-zoom-controls"))||(e.preventDefault(),i(1.5*r))};e.addEventListener("wheel",a,{passive:!1}),e.addEventListener("dblclick",s);const l=.4,c=t=>{if(0!==t.button)return;const n=t.target;if(n.closest("button")||n.closest(".stream-geo-zoom-controls"))return;const o=_e.current;if(!o)return;const r=o.getRotation();st.current={x:t.clientX,y:t.clientY,rotation:[...r]},e.setPointerCapture(t.pointerId),t.preventDefault()},u=e=>{const t=st.current;t&&(lt.current=[t.rotation[0]+(e.clientX-t.x)*l,Math.max(-90,Math.min(90,t.rotation[1]-(e.clientY-t.y)*l)),t.rotation[2]],Rt())},d=t=>{var n;if(!st.current)return;st.current=null,e.releasePointerCapture(t.pointerId);const r=lt.current;if(r){lt.current=null;const e=_e.current;e&&(e.applyRotation(r,o),Rt())}const i=_e.current;i&&(null==B||B({projection:null===(n=i.scales)||void 0===n?void 0:n.projection,zoom:i.currentZoom}))};return e.addEventListener("pointerdown",c),e.addEventListener("pointermove",u),e.addEventListener("pointerup",d),e.addEventListener("pointercancel",d),()=>{e.removeEventListener("wheel",a),e.removeEventListener("dblclick",s),e.removeEventListener("pointerdown",c),e.removeEventListener("pointermove",u),e.removeEventListener("pointerup",d),e.removeEventListener("pointercancel",d),ot.current=null}}const r=_().scaleExtent([t,n]).extent([[0,0],[Ie[0],Ie[1]]]).translateExtent([[-1/0,-1/0],[1/0,1/0]]).on("zoom",e=>{const t=e.transform;rt.current=t,it.current=!0;const n=_e.current;n&&(n.applyZoomTransform(t,o),Ye.current=!1,Rt())}).on("end",e=>{var t;rt.current=e.transform,it.current=!1;const n=_e.current;n&&(null==B||B({projection:null===(t=n.scales)||void 0===t?void 0:t.projection,zoom:n.currentZoom}))});return ot.current=r,H(e).call(r),()=>{H(e).on(".zoom",null)}},[P,I,We,Ie,Ne,De,Be,B,Rt]);const en=re&&!1!==ie,tn=en&&Pt?ae?ae(Pt):e.createElement(qt,{data:Pt}):null,nn=tn?e.createElement(ft,{x:Pt.x,y:Pt.y,containerWidth:Ne,containerHeight:De,margin:Be,className:"stream-frame-tooltip",zIndex:10},tn):null;if(Je){const t=_e.current;t&&(A||j||E)&&(A&&t.setAreas(A),j&&t.setPoints(j),E&&t.setLines(E),t.computeScene({width:Ne,height:De}));const n=null!==(c=null==t?void 0:t.scene)&&void 0!==c?c:[];return e.createElement("div",{className:"stream-geo-frame"+(J?" "+J:""),role:"img","aria-label":Se||("string"==typeof be?be:"Geographic chart"),style:{position:"relative",width:Ie[0],height:Ie[1]}},e.createElement(dt,{summary:Me}),e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:Ie[0],height:Ie[1],style:{position:"absolute",left:0,top:0}},e.createElement("g",{transform:`translate(${Be.left},${Be.top})`},Re),e.createElement("g",{transform:`translate(${Be.left},${Be.top})`},Q&&e.createElement("rect",{x:0,y:0,width:Ne,height:De,fill:Q}),n.map((t,n)=>function(t,n){var o,r,i,a,s,l;switch(t.type){case"geoarea":{const i=t;return i.pathData?e.createElement("path",{key:"geoarea-"+n,d:i.pathData,fill:Ke(i.style.fill,"#e0e0e0"),fillOpacity:null!==(o=i.style.fillOpacity)&&void 0!==o?o:1,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth||.5,strokeDasharray:i.style.strokeDasharray,opacity:null!==(r=i._decayOpacity)&&void 0!==r?r:1}):null}case"point":{const o=t;return e.createElement("circle",{key:"point-"+n,cx:o.x,cy:o.y,r:o.r,fill:Ke(o.style.fill),fillOpacity:null!==(i=o.style.fillOpacity)&&void 0!==i?i:.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:null!==(a=o._decayOpacity)&&void 0!==a?a:null!==(s=o.style.opacity)&&void 0!==s?s:1})}case"line":{const o=t;if(2>o.path.length)return null;const r="M"+o.path.map(e=>`${e[0]},${e[1]}`).join("L");return e.createElement("path",{key:"line-"+n,d:r,fill:"none",stroke:o.style.stroke||"#4e79a7",strokeWidth:o.style.strokeWidth||1.5,strokeDasharray:o.style.strokeDasharray,opacity:null!==(l=o.style.opacity)&&void 0!==l?l:1})}default:return null}}(t,n)))),e.createElement(Xe,{width:Ne,height:De,totalWidth:Ie[0],totalHeight:Ie[1],margin:Be,scales:null,showAxes:!1,title:be,legend:ve,legendPosition:xe,legendHoverBehavior:ke,legendClickBehavior:we,legendHighlightedCategory:Ae,legendIsolatedCategories:je,foregroundGraphics:Te,annotations:ce,annotationFrame:0,xValues:[],yValues:[],pointNodes:n.filter(e=>"point"===e.type)}))}const on=l(e=>{at.current=e,Pe&&"object"==typeof Pe&&(Pe.current=e)},[Pe]);return e.createElement("div",{ref:on,className:"stream-geo-frame"+(J?" "+J:""),role:"group","aria-label":Se||("string"==typeof be?be:"Geographic chart"),tabIndex:0,style:Object.assign({position:"relative",width:Y?"100%":Ie[0],height:X?"100%":Ie[1],overflow:"hidden"},P?{touchAction:"none"}:{}),onKeyDown:Jt},Oe&&e.createElement(pt,{tableId:ze}),Oe&&e.createElement(ut,{scene:null!==(p=null===(d=_e.current)||void 0===d?void 0:d.scene)&&void 0!==p?p:[],chartType:"Geographic chart",tableId:ze,chartTitle:"string"==typeof be?be:void 0}),e.createElement(dt,{summary:Me}),e.createElement("div",{role:"img","aria-label":Se||("string"==typeof be?be:"Geographic chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:en?Qt:void 0,onMouseLeave:en?Zt:void 0,onClick:se?Yt:void 0},Re&&e.createElement("svg",{style:{position:"absolute",left:0,top:0,width:Ie[0],height:Ie[1],pointerEvents:"none"}},e.createElement("g",{transform:`translate(${Be.left},${Be.top})`},Re)),W&&e.createElement("canvas",{ref:He,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),e.createElement("canvas",{ref:qe,"aria-label":tt(null!==(y=null===(h=_e.current)||void 0===h?void 0:h.scene)&&void 0!==y?y:[],"Geographic chart"),style:{position:"absolute",left:0,top:0}}),e.createElement("canvas",{ref:Ge,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),e.createElement(ht,{hoverPoint:Pt}),e.createElement(Xe,{width:Ne,height:De,totalWidth:Ie[0],totalHeight:Ie[1],margin:Be,scales:null,showAxes:null!=Ee&&Ee,title:be,legend:ve,legendPosition:xe,legendHoverBehavior:ke,legendClickBehavior:we,legendHighlightedCategory:Ae,legendIsolatedCategories:je,foregroundGraphics:Te,annotations:ce,annotationFrame:Bt,xValues:[],yValues:[],pointNodes:null===(g=_e.current)||void 0===g?void 0:g.scene.filter(e=>"point"===e.type)}),(null==ye?void 0:ye.showBadge)&&e.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===ye.badgePosition?{top:4,left:4}:"bottom-left"===ye.badgePosition?{bottom:4,left:4}:"bottom-right"===ye.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:Dt?"#dc3545":"#28a745",color:"white"})},Dt?"STALE":"LIVE"),P&&e.createElement("div",{className:"stream-geo-zoom-controls",style:{position:"absolute",bottom:Be.bottom+8,left:Be.left+8,display:"flex",flexDirection:"column",gap:2,zIndex:2}},e.createElement("button",{type:"button","aria-label":"Zoom in",onClick:e=>{e.stopPropagation();const t=at.current,n=ot.current;t&&(null==n?void 0:n.scaleBy)&&n.scaleBy(H(t),1.5)},style:Ht},"+"),e.createElement("button",{type:"button","aria-label":"Zoom out",onClick:e=>{e.stopPropagation();const t=at.current,n=ot.current;t&&(null==n?void 0:n.scaleBy)&&n.scaleBy(H(t),1/1.5)},style:Ht},"−")),q&&e.createElement("div",{className:"stream-geo-tile-attribution",style:{position:"absolute",bottom:Be.bottom+2,right:Be.right+4,fontSize:10,color:"rgba(0,0,0,0.6)",background:"rgba(255,255,255,0.7)",padding:"1px 4px",borderRadius:2,pointerEvents:"none",zIndex:2}},q),e.createElement(gt,{active:Xt.current>=0,hoverPoint:Pt,margin:Be,size:Ie,shape:null===(f=Kt.current)||void 0===f?void 0:f.shape,width:null===(m=Kt.current)||void 0===m?void 0:m.w,height:null===(b=Kt.current)||void 0===b?void 0:b.h}),nn))});Gt.displayName="StreamGeoFrame";const Vt={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, white)",padding:"8px 12px",borderRadius:"var(--semiotic-tooltip-radius, 6px)",fontSize:"var(--semiotic-tooltip-font-size, 14px)",fontFamily:"var(--semiotic-font-family, inherit)",lineHeight:"1.5",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.15))",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function Ut(e,t){return"function"==typeof t?t(e):e[t]}function Zt(e,t){if(t)return t(e);if(null==e)return"";if("number"==typeof e){if(!Number.isFinite(e))return e+"";const t=Number.isInteger(e)?e:parseFloat(e.toPrecision(6));return Math.abs(t)>9999?t.toLocaleString():t+""}return e instanceof Date?e.toLocaleDateString():"object"==typeof e&&null!==e?void 0!==e.id?e.id+"":void 0!==e.name?e.name+"":JSON.stringify(e):e+""}function Yt(t={}){const{fields:n,title:o,format:r,style:i={},className:a=""}=t;return t=>{if(!t||"object"!=typeof t)return null;let s;const l=[];if(o){const e=Ut(t,o);s=Zt(e,r)}if(n&&n.length>0)n.forEach(e=>{let n,o,i;"string"==typeof e?(n=e,o=e,i=r):(n=e.label,o=e.accessor||e.key||"",i=e.format||r);const a=Ut(t,o);l.push({label:n,value:Zt(a,i)})});else if(!o){const e=["value","y","name","id","label"];for(const n of e)if(void 0!==t[n]){s=Zt(t[n],r);break}if(!s){const e=Object.keys(t).filter(e=>!e.startsWith("_"));e.length>0&&(s=Zt(t[e[0]],r))}}const c=Object.assign(Object.assign({},Vt),i);return e.createElement("div",{className:("semiotic-tooltip "+a).trim(),style:c},s&&e.createElement("div",{style:{fontWeight:l.length>0?"bold":"normal"}},s),l.map((t,n)=>e.createElement("div",{key:n,style:{marginTop:0===n&&s?"4px":0}},t.label&&e.createElement("span",null,t.label,": "),t.value)))}}function Xt(t){if(!0===t)return Yt();if("function"==typeof t){const n=t;return t=>{const o=n(!t||"object"!=typeof t.data||null===t.data||"node"!==t.type&&"edge"!==t.type?t:t.data);return null==o?null:e.createElement("div",{className:"semiotic-tooltip",style:Vt},o)}}return!1!==t&&void 0!==t&&("object"==typeof t&&null!==t&&("fields"in t||"title"in t)?Yt(t):Yt())}const Kt={category10:q,tableau10:Q,set3:J,blues:K,reds:X,greens:Y,oranges:Z,purples:U,viridis:V,plasma:G},Jt=q,Qt=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],en=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function tn(e,t,n){if("function"==typeof t){const o=t(e);return n&&o&&"string"==typeof o&&!function(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||en.has(t)}(o)?n(o):o}const o=e[t];return n?n(o):Jt[Math.abs(function(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n),t&=t;return Math.abs(t)}(o+""))%Jt.length]}function nn(e,t,n="category10"){const o=Array.from(new Set(e.map(e=>null==e?void 0:e[t]).filter(e=>null!=e))),r=o.every(e=>"number"==typeof e||!isNaN(Number(e)));if(Array.isArray(n))return A().domain(o).range(n).unknown("#999");const i=Kt[n]||Kt.category10;if(r&&"function"==typeof i){let e=-1/0;for(const t of o){const n=Number(t);n>e&&(e=n)}return t=>i(Number(t)/e)}{const e=Array.isArray(i)?i:Jt;return A().domain(o).range(e).unknown("#999")}}function on(e,t,n=[3,20],o){let r;if(r="function"==typeof t?t(e):e[t],!o)return r;const[i,a]=o,[s,l]=n;return a===i?(s+l)/2:s+(r-i)/(a-i)*(l-s)}const rn=a(null);function an(e){const t=[];for(const[n,o]of Object.entries(e.fields))if("point"===o.type)t.push(e=>o.values.has(e[n]));else{const[e,r]=o.range;t.push(t=>{const o=t[n];return o>=e&&r>=o})}return e=>t.every(t=>t(e))}function sn(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}const[ln,cn]=It(e=>({selections:new Map,setClause(t,n){e(e=>{const o=new Map(e.selections),r=sn(o,t),i=new Map(r.clauses);return i.set(n.clientId,n),o.set(t,Object.assign(Object.assign({},r),{clauses:i})),{selections:o}})},clearClause(t,n){e(e=>{const o=e.selections.get(t);if(!o)return{};const r=new Map(e.selections),i=new Map(o.clauses);return i.delete(n),r.set(t,Object.assign(Object.assign({},o),{clauses:i})),{selections:r}})},setResolution(t,n){e(e=>{const o=new Map(e.selections),r=sn(o,t);return o.set(t,Object.assign(Object.assign({},r),{resolution:n})),{selections:o}})},clearSelection(t){e(e=>{const n=new Map(e.selections),o=n.get(t);return o&&n.set(t,Object.assign(Object.assign({},o),{clauses:new Map})),{selections:n}})}})),[un,dn]=It(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const n=e.observations;return n.push(t),n.length>e.maxObservations&&n.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}}));function pn(e){const t=d(),n=e.clientId||t,{name:o}=e,i=cn(e=>e.selections.get(o)),a=cn(e=>e.setClause),s=cn(e=>e.clearClause),c=r(()=>!!i&&i.clauses.size>0,[i]);return{predicate:r(()=>i&&0!==i.clauses.size?function(e,t){const n=[];for(const[o,r]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(an(r));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(i,n):()=>!0,[i,n]),isActive:c,selectPoints:l(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"point",values:new Set(o)};a(o,{clientId:n,type:"point",fields:t})},[n,o,a]),selectInterval:l(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"interval",range:o};a(o,{clientId:n,type:"interval",fields:t})},[n,o,a]),clear:l(()=>{s(o,n)},[s,o,n]),clientId:n}}function hn(e){const t=e.name||"hover",{fields:n}=e,{predicate:o,isActive:r,selectPoints:i,clear:a}=pn({name:t});return{onHover:l(e=>{if(!e)return void a();const t={};for(const o of n){const n=e[o];void 0!==n&&(t[o]=[n])}Object.keys(t).length>0&&i(t)},[n,i,a,t]),predicate:o,isActive:r}}const yn=a(!1);function gn(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields||t||[],mode:e.mode,xField:e.xField}:null}function fn(e,t,n){return t?o=>{var r;const i=Object.assign({},e(o));if(t.isActive)if(t.predicate(o))(null==n?void 0:n.selectedStyle)&&Object.assign(i,n.selectedStyle);else{const e=null!==(r=null==n?void 0:n.unselectedOpacity)&&void 0!==r?r:.2;i.opacity=e,i.fillOpacity=e,i.strokeOpacity=e,(null==n?void 0:n.unselectedStyle)&&Object.assign(i,n.unselectedStyle)}return i}:e}e.createContext(void 0);const mn="#007bff";function bn(e,t,n){const o=s(rn),i=function(){var e;const t=Wt(e=>e.theme),n=null===(e=null==t?void 0:t.colors)||void 0===e?void 0:e.categorical;return n&&n.length>0?n:void 0}();return r(()=>{var r;if(!t)return;const a=null!==(r=null!=n?n:i&&i.length>0?i:void 0)&&void 0!==r?r:"category10";if(0!==e.length){if("function"==typeof t){const n=Array.from(new Set(e.map(e=>t(e)+"")));if(o&&Object.keys(o).length>0){const e=nn(n.map(e=>({_cat:e})),"_cat",a);return t=>o[t]||e(t)}return nn(n.map(e=>({_cat:e})),"_cat",a)}if(o&&Object.keys(o).length>0){const n=nn(e,t,a);return e=>o[e]||n(e)}return nn(e,t,a)}if(o&&Object.keys(o).length>0){const e=nn([{_:"a"}],"_",a);return t=>o[t]||e(t)}},[e,t,n,o,i])}function vn({selection:e,linkedHover:t,fallbackFields:i=[],unwrapData:a=!1,onObservation:s,chartType:c,chartId:u,onClick:p,hoverHighlight:h,colorByField:y}){const g=d(),f=gn(t,i),m=pn({name:(null==e?void 0:e.name)||"__unused__"}),b=hn({name:(null==f?void 0:f.name)||"hover",fields:(null==f?void 0:f.fields)||i||[]}),v=dn(e=>e.pushObservation),x=e?{isActive:m.isActive,predicate:m.predicate}:null,[k,w]=n(null),A=y||i[0],j=r(()=>{if(!h||null==k||!A)return null;const e=k,t=A;return{isActive:!0,predicate:n=>{var o;return("string"==typeof n[t]?n[t]:(null!==(o=n[t])&&void 0!==o?o:"")+"")===e}}},[h,k,A]),E=l(e=>{var n,o;if(t)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"x-position"===(null==f?void 0:f.mode)&&f.xField){const e=null==t?void 0:t[f.xField];null!=e&&Number.isFinite(Number(e))&&function(e,t,n){const o=Ne.positions.get(e);(null==o?void 0:o.locked)||o&&o.xValue===t&&o.sourceId===n||(Ne={positions:new Map(Ne.positions).set(e,{xValue:t,sourceId:n})},Te())}(f.name||"hover",Number(e),g)}"x-position"!==(null==f?void 0:f.mode)&&b.onHover(t)}else"x-position"===(null==f?void 0:f.mode)&&Re(f.name||"hover",g),"x-position"!==(null==f?void 0:f.mode)&&b.onHover(null);if(h&&A)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=null==t?void 0:t[A];w(null!=n?n+"":null)}else w(null);if(s||v){const t={timestamp:Date.now(),chartType:c||"unknown",chartId:u};if(e){let r=e.data||e.datum||e;Array.isArray(r)&&(r=r[0]);const i=Object.assign(Object.assign({},t),{type:"hover",datum:r||{},x:null!==(n=e.x)&&void 0!==n?n:0,y:null!==(o=e.y)&&void 0!==o?o:0});s&&s(i),v&&v(i)}else{const e=Object.assign(Object.assign({},t),{type:"hover-end"});s&&s(e),v&&v(e)}}},[t,b,f,g,s,c,u,v,h,A]),O=l(e=>{var t,n,o,r;if("x-position"===(null==f?void 0:f.mode)&&f.xField&&e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=null==t?void 0:t[f.xField];null!=n&&Number.isFinite(Number(n))&&function(e,t,n){const o=Ne.positions.get(e);if(null==o?void 0:o.locked){const t=new Map(Ne.positions);return t.delete(e),Ne={positions:t},Te(),!1}Ne={positions:new Map(Ne.positions).set(e,{xValue:t,sourceId:n,locked:!0})},Te()}(f.name||"hover",Number(n),g)}if(e&&p){let o=e.data||e.datum||e;Array.isArray(o)&&(o=o[0]),p(o,{x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0})}if(s||v){const t={timestamp:Date.now(),chartType:c||"unknown",chartId:u};if(e){let n=e.data||e.datum||e;Array.isArray(n)&&(n=n[0]);const i=Object.assign(Object.assign({},t),{type:"click",datum:n||{},x:null!==(o=e.x)&&void 0!==o?o:0,y:null!==(r=e.y)&&void 0!==r?r:0});s&&s(i),v&&v(i)}else{const e=Object.assign(Object.assign({},t),{type:"click-end"});s&&s(e),v&&v(e)}}},[p,s,v,c,u,f,g]);return o(()=>{if("x-position"!==(null==f?void 0:f.mode))return;const e=f.name||"hover";return()=>{We(e,g),Re(e,g)}},[null==f?void 0:f.mode,null==f?void 0:f.name,g]),{activeSelectionHook:x,hoverSelectionHook:j,customHoverBehavior:E,customClickBehavior:O,crosshairSourceId:g}}function xn({data:e,colorBy:t,colorScale:n,showLegend:o,legendPosition:i="right",userMargin:a,defaults:l={top:50,bottom:60,left:70,right:40},categories:c}){const u=s(yn),d=void 0!==o?o:!u&&!!t,p=r(()=>{if(d&&t)return function({data:e,colorBy:t,colorScale:n,getColor:o,strokeColor:r,strokeWidth:i,categories:a}){return{legendGroups:[{styleFn:e=>{const t=e.color||"#333",n={fill:t,stroke:t};return void 0!==r&&(n.stroke=r),void 0!==i&&(n.strokeWidth=i),n},type:"fill",items:(a&&a.length>0?a:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t])))).map((r,i)=>{const a=e.find("function"==typeof t?e=>t(e)===r:e=>e[t]===r),s=a?o(a,t,n):n?n(r):Qt[i%Qt.length];return{label:r+"",color:s}}),label:""}]}}({data:e,colorBy:t,colorScale:n,getColor:tn,categories:c})},[d,t,e,n,c]),h=r(()=>{const e=Object.assign(Object.assign({},l),a);return p&&("right"===i&&110>e.right?e.right=110:"left"===i&&110>e.left?e.left=110:"top"===i&&50>e.top?e.top=50:"bottom"===i&&80>e.bottom&&(e.bottom=80)),e},[l,a,p,i]);return{legend:p,margin:h,legendPosition:i}}const kn={primary:{width:600,height:400,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:void 0,showLabels:void 0,marginDefaults:{top:50,bottom:60,left:70,right:40}},context:{width:400,height:250,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:10,bottom:10,left:10,right:10}},sparkline:{width:120,height:24,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:2,bottom:2,left:0,right:0}}};function wn(e,t,n){var o,r,i,a,s,l;const c=kn[e||"primary"],u="context"===e||"sparkline"===e;return{width:null!==(o=t.width)&&void 0!==o?o:c.width,height:null!==(r=t.height)&&void 0!==r?r:c.height,showAxes:c.showAxes,showGrid:null!==(i=t.showGrid)&&void 0!==i?i:c.showGrid,enableHover:null!==(a=t.enableHover)&&void 0!==a?a:!!t.linkedHover||c.enableHover,showLegend:null!==(s=t.showLegend)&&void 0!==s?s:c.showLegend,showLabels:null!==(l=t.showLabels)&&void 0!==l?l:c.showLabels,title:u?void 0:t.title,description:t.description,summary:t.summary,accessibleTable:t.accessibleTable,xLabel:u?void 0:t.xLabel,yLabel:u?void 0:t.yLabel,categoryLabel:u?void 0:t.categoryLabel,valueLabel:u?void 0:t.valueLabel,marginDefaults:An(c.marginDefaults,t.showCategoryTicks,t.orientation)}}function An(e,t,n){if(!1!==t)return e;const o=Object.assign({},e);return"horizontal"===n?o.left=Math.min(o.left,15):o.bottom=Math.min(o.bottom,15),o}function jn({componentName:t,message:n,diagnosticHint:o,width:r,height:i}){return e.createElement("div",{role:"alert",style:{width:r,height:Math.max(i,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"}},e.createElement("div",{style:{textAlign:"center",maxWidth:400}},e.createElement("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"}},t),e.createElement("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5}},n),o&&e.createElement("div",{"data-testid":"semiotic-diagnostic-hint",style:{marginTop:10,padding:"8px 12px",background:"rgba(128, 128, 128, 0.06)",borderRadius:4,fontSize:12,color:"rgba(128, 128, 128, 0.8)",fontFamily:"monospace",textAlign:"left",whiteSpace:"pre-wrap",lineHeight:1.6}},o)))}class En extends e.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){var n,o;null===(o=(n=this.props).onError)||void 0===o||o.call(n,e,t)}render(){if(this.state.error){const{fallback:t}=this.props,n=this.state.error;return"function"==typeof t?t(n):void 0!==t?t:e.createElement(jn,{componentName:"ChartErrorBoundary",message:n.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}function On(e,t){const n=e.length,o=t.length,r=Array(o+1);for(let e=0;o>=e;e++)r[e]=e;for(let i=1;n>=i;i++){let n=r[0];r[0]=i;for(let a=1;o>=a;a++){const o=r[a];r[a]=e[i-1]===t[a-1]?n:1+Math.min(n,r[a],r[a-1]),n=o}}return r[o]}function Sn(e,t,n=3){let o,r=n+1;for(const n of t){const t=On(e.toLowerCase(),n.toLowerCase());r>t&&(r=t,o=n)}return r>n?void 0:o}function Mn(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}function Cn(e,t){var n;if(0===t.length)return null;const o=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(o)||o.includes(e.toLowerCase()))||(null!==(n=Sn(e,t,3))&&void 0!==n?n:null)}const $n={width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},frameProps:{type:"object"},onClick:{type:"function"}},zn={xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"}},Ln={categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"},categoryFormat:{type:"function"}},Pn=["linear","monotoneX","monotoneY","step","stepAfter","stepBefore","basis","cardinal","catmullRom"],In=["vertical","horizontal"],Bn={LineChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},$n),zn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},lineBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Pn},lineWidth:{type:"number"},showPoints:{type:"boolean"},pointRadius:{type:"number"},fillArea:{type:"boolean"},areaOpacity:{type:"number"}})},AreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},$n),zn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Pn},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"}})},StackedAreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},$n),zn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Pn},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"},normalize:{type:"boolean"}})},Scatterplot:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},$n),zn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"}})},BubbleChart:{required:["data","sizeBy"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},$n),zn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},bubbleOpacity:{type:"number"},bubbleStrokeWidth:{type:"number"},bubbleStrokeColor:{type:"string"}})},Heatmap:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},$n),zn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},colorScheme:{type:"string",enum:["blues","reds","greens","viridis","custom"]},customColorScale:{type:["object","function"]},showValues:{type:"boolean"},valueFormat:{type:"function"},cellBorderColor:{type:"string"},cellBorderWidth:{type:"number"},showLegend:{type:"boolean"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}})},QuadrantChart:{required:["quadrants"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},$n),zn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},quadrants:{type:"object"},xCenter:{type:"number"},yCenter:{type:"number"},centerlineStyle:{type:"object"},showQuadrantLabels:{type:"boolean"},quadrantLabelSize:{type:"number"},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"}})},MultiAxisLineChart:{required:["series"],dataShape:"array",dataAccessors:["xAccessor"],props:Object.assign(Object.assign(Object.assign({},$n),zn),{data:{type:"array"},xAccessor:{type:["string","function"]},series:{type:"array"},colorScheme:{type:["string","array"]},curve:{type:"string"},lineWidth:{type:"number"},annotations:{type:"array"}})},ConnectedScatterplot:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},$n),zn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},orderAccessor:{type:["string","function"]},orderLabel:{type:"string"},pointRadius:{type:"number"},pointIdAccessor:{type:["string","function"]},annotations:{type:"array"}})},BarChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},$n),Ln),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:In},sort:{type:["boolean","string","function"]},barPadding:{type:"number"}})},StackedBarChart:{required:["data","stackBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},$n),Ln),{data:{type:"array"},categoryAccessor:{type:["string","function"]},stackBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:In},normalize:{type:"boolean"},barPadding:{type:"number"}})},LikertChart:{required:["levels"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor","levelAccessor","countAccessor"],props:Object.assign(Object.assign(Object.assign({},$n),Ln),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},levelAccessor:{type:["string","function"]},countAccessor:{type:["string","function"]},levels:{type:"array"},orientation:{type:"string",enum:In},barPadding:{type:"number"}})},GroupedBarChart:{required:["data","groupBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},$n),Ln),{data:{type:"array"},categoryAccessor:{type:["string","function"]},groupBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:In},barPadding:{type:"number"}})},SwarmPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},$n),Ln),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:In},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},BoxPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},$n),Ln),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:In},showOutliers:{type:"boolean"},outlierRadius:{type:"number"},categoryPadding:{type:"number"}})},Histogram:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},$n),Ln),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},bins:{type:"number"},relative:{type:"boolean"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},ViolinPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},$n),Ln),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:In},bins:{type:"number"},curve:{type:"string"},showIQR:{type:"boolean"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},RidgelinePlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},$n),Ln),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},bins:{type:"number"},amplitude:{type:"number"},categoryPadding:{type:"number"}})},DotPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},$n),Ln),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:In},sort:{type:["boolean","string","function"]},dotRadius:{type:"number"},categoryPadding:{type:"number"}})},PieChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},$n),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},startAngle:{type:"number"}})},DonutChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},$n),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},innerRadius:{type:"number"},centerContent:{type:["object","string","number"]},startAngle:{type:"number"}})},GaugeChart:{required:["value"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},$n),{value:{type:"number"},min:{type:"number"},max:{type:"number"},thresholds:{type:"array"},arcWidth:{type:"number"},sweep:{type:"number"},showNeedle:{type:"boolean"},needleColor:{type:"string"},centerContent:{type:["object","string","number","function"]},valueFormat:{type:"function"},showScaleLabels:{type:"boolean"},backgroundColor:{type:"string"}})},FunnelChart:{required:["data"],dataShape:"array",dataAccessors:["stepAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},$n),Ln),{data:{type:"array"},stepAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},orientation:{type:"string",enum:["horizontal","vertical"]},connectorOpacity:{type:"number"},showCategoryTicks:{type:"boolean"},responsiveWidth:{type:"boolean"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}})},SwimlaneChart:{required:["subcategoryAccessor"],dataShape:"array",dataAccessors:["categoryAccessor","subcategoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},$n),Ln),{data:{type:"array"},categoryAccessor:{type:["string","function"]},subcategoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:["horizontal","vertical"]},barPadding:{type:"number"},showCategoryTicks:{type:"boolean"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]},responsiveWidth:{type:"boolean"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}})},ForceDirectedGraph:{required:["nodes","edges"],dataShape:"network",dataAccessors:["nodeIDAccessor","sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},$n),{nodes:{type:"array"},edges:{type:"array"},nodeIDAccessor:{type:["string","function"]},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},nodeLabel:{type:["string","function"]},nodeSize:{type:["number","string","function"]},nodeSizeRange:{type:"array"},edgeWidth:{type:["number","string","function"]},edgeColor:{type:"string"},edgeOpacity:{type:"number"},iterations:{type:"number"},forceStrength:{type:"number"},showLabels:{type:"boolean"}})},SankeyDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},$n),{nodes:{type:"array"},edges:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target","gradient"]},orientation:{type:"string",enum:In},nodeAlign:{type:"string",enum:["justify","left","right","center"]},nodePaddingRatio:{type:"number"},nodeWidth:{type:"number"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"},edgeSort:{type:"function"}})},ChordDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},$n),{nodes:{type:"array"},edges:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target"]},padAngle:{type:"number"},groupWidth:{type:"number"},sortGroups:{type:"function"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"}})},TreeDiagram:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},$n),{data:{type:"object"},layout:{type:"string",enum:["tree","cluster","partition","treemap","circlepack"]},orientation:{type:"string",enum:["vertical","horizontal","radial"]},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},edgeStyle:{type:"string",enum:["line","curve"]},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},nodeSize:{type:"number"}})},Treemap:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},$n),{data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]}})},CirclePack:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},$n),{data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]},circleOpacity:{type:"number"}})},OrbitDiagram:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},$n),{data:{type:"object"},childrenAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},orbitMode:{type:["string","array"]},speed:{type:"number"},revolution:{type:"function"},eccentricity:{type:["number","function"]},orbitSize:{type:["number","function"]},nodeRadius:{type:["number","function"]},showRings:{type:"boolean"},showLabels:{type:"boolean"},animated:{type:"boolean"},colorByDepth:{type:"boolean"},annotations:{type:"array"},foregroundGraphics:{type:"object"}})},RealtimeLineChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},stroke:{type:"string"},strokeWidth:{type:"number"},strokeDasharray:{type:"string"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeHistogram:{required:["binSize"],dataShape:"realtime",dataAccessors:[],props:{binSize:{type:"number"},size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},fill:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},gap:{type:"number"},brush:{type:["boolean","string","object"]},onBrush:{type:"function"},linkedBrush:{type:["string","object"]},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeSwarmChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},radius:{type:"number"},fill:{type:"string"},opacity:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeWaterfallChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},positiveColor:{type:"string"},negativeColor:{type:"string"},connectorStroke:{type:"string"},connectorWidth:{type:"number"},gap:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeHeatmap:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},heatmapXBins:{type:"number"},heatmapYBins:{type:"number"},aggregation:{type:"string",enum:["count","sum","mean"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"}}}};function Nn(e,t){return(Array.isArray(t)?t:[t]).includes(Array.isArray(e)?"array":typeof e)}const Dn=new Set(["TreeDiagram","Treemap","CirclePack","OrbitDiagram"]),Tn=new Set(["ForceDirectedGraph","SankeyDiagram","ChordDiagram"]),Rn=new Set(["BarChart","StackedBarChart","GroupedBarChart","AreaChart","StackedAreaChart"]),Wn=new Set(["LineChart","AreaChart","StackedAreaChart"]),Fn=new Set(["BarChart","StackedBarChart","GroupedBarChart","FunnelChart"]);function _n(e){const t=e.match(/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i);if(!t)return null;const[n,o,r]=[parseInt(t[1],16)/255,parseInt(t[2],16)/255,parseInt(t[3],16)/255],i=e=>e>.03928?Math.pow((e+.055)/1.055,2.4):e/12.92;return.2126*i(n)+.7152*i(o)+.0722*i(r)}function Hn(e,t){const n=_n(e),o=_n(t);return null===n||null===o?null:(Math.max(n,o)+.05)/(Math.min(n,o)+.05)}const qn=["xAccessor","yAccessor","timeAccessor","valueAccessor","categoryAccessor","colorBy","sizeBy","lineBy","areaBy","stackBy","groupBy","orderAccessor","y0Accessor","sourceAccessor","targetAccessor","nodeIDAccessor","childrenAccessor","costAccessor"];function Gn(e,t){const n=[],o=function(e,t){const n=[],o=Bn[e];if(!o)return{valid:!1,errors:[`Unknown component "${e}". Valid components: ${Object.keys(Bn).join(", ")}`]};for(const r of o.required)null==t[r]&&n.push(`"${r}" is required for ${e}.`);for(const[e,r]of Object.entries(t)){if(null==r)continue;const t=o.props[e];if(t){if(!Nn(r,t.type)){const o=Array.isArray(t.type)?t.type.join(" | "):t.type;n.push(`"${e}" should be ${o}, got ${Array.isArray(r)?"array":typeof r}.`);continue}t.enum&&"string"==typeof r&&!t.enum.includes(r)&&n.push(`"${e}" value "${r}" is not valid. Expected one of: ${t.enum.join(", ")}.`)}}const r=Object.keys(o.props),i=new Set(r);for(const o of Object.keys(t))if(void 0!==t[o]&&!i.has(o)){const t=Sn(o,r),i=t?`Unknown prop "${o}" for ${e}. Did you mean "${t}"?`:`Unknown prop "${o}" for ${e}. Valid props: ${r.join(", ")}.`;n.push(i)}if("array"===o.dataShape){const r=t.data,i={};for(const e of o.dataAccessors){const n=t[e];"string"==typeof n&&(i[e]=n)}const a=function({componentName:e,data:t,accessors:n,requiredProps:o}){if(o)for(const[t,n]of Object.entries(o))if(null==n)return`${e}: ${t} is required. Provide a field name or function.`;if(null==t)return null;if(!Array.isArray(t)||0===t.length)return e+": No data provided. Pass a non-empty array to the data prop.";if(!Array.isArray(t)&&"object"==typeof t)return e+": data should be an array, but received an object. If this is hierarchical data, use TreeDiagram, Treemap, or CirclePack instead.";if(n){const o=Mn(t).find(e=>e&&"object"==typeof e);if(o){const t=Object.keys(o);for(const[r,i]of Object.entries(n))if(i&&"string"==typeof i&&!(i in o)){const n=Cn(i,t),o=n?` Try ${r}="${n}".`:"";return`${e}: ${r} "${i}" not found in data. Available fields: ${t.join(", ")}.${o}`}}}return null}({componentName:e,data:r,accessors:Object.keys(i).length>0?i:void 0});a&&n.push(a)}else if("object"===o.dataShape){const o=function({componentName:e,data:t,dataLabel:n="data"}){return null==t?`${e}: No ${n} provided. Pass a hierarchical object with children: { name: "root", children: [...] }.`:Array.isArray(t)?`${e}: ${n} should be a single root object, not an array. Expected: { name: "root", children: [...] }. If you have flat data, use LineChart, BarChart, or Scatterplot instead.`:null}({componentName:e,data:t.data});o&&n.push(o)}else if("network"===o.dataShape){const r=function({componentName:e,nodes:t,edges:n,nodesRequired:o=!1,edgesRequired:r=!0,accessors:i}){if(null==t&&null==n)return null;if(r&&(!n||!Array.isArray(n)||0===n.length))return e+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(o&&(!t||!Array.isArray(t)||0===t.length))return e+': No nodes provided. Pass a non-empty array: nodes={[{ id: "A" }, { id: "B" }, ...]}.';if(i&&t&&t.length>0){const n=Mn(t).find(e=>e&&"object"==typeof e);if(n){const t=Object.keys(n);for(const[o,r]of Object.entries(i))if(r&&"string"==typeof r&&!(r in n)){const n=Cn(r,t),i=n?` Try ${o}="${n}".`:"";return`${e}: ${o} "${r}" not found in node data. Available fields: ${t.join(", ")}.${i}`}}}return null}({componentName:e,nodes:t.nodes,edges:t.edges,nodesRequired:o.required.includes("nodes"),edgesRequired:o.required.includes("edges")});r&&n.push(r)}return{valid:0===n.length,errors:n}}(e,t);for(const e of o.errors)n.push({severity:"error",code:"VALIDATION",message:e,fix:""});return Bn[e]?(function(e,t,n){const o=Bn[e];if(o){if("array"===o.dataShape){const e=t.data;e&&Array.isArray(e)&&0===e.length&&n.push({severity:"error",code:"EMPTY_DATA",message:"data is an empty array — chart will render blank.",fix:"Provide at least one data point: data={[{ x: 1, y: 2 }]}."})}"network"===o.dataShape&&t.edges&&Array.isArray(t.edges)&&0===t.edges.length&&n.push({severity:"error",code:"EMPTY_EDGES",message:"edges is an empty array — network chart will render blank.",fix:'Provide at least one edge: edges={[{ source: "A", target: "B" }]}.'})}}(e,t,n),function(e,t,n){const o=t.width,r=t.height;if(void 0===o||"number"==typeof o&&o>0||n.push({severity:"error",code:"BAD_WIDTH",message:`width=${JSON.stringify(o)} — chart needs a positive number.`,fix:"Set width={600} or use responsiveWidth={true}."}),void 0===r||"number"==typeof r&&r>0||n.push({severity:"error",code:"BAD_HEIGHT",message:`height=${JSON.stringify(r)} — chart needs a positive number.`,fix:"Set height={400} or use responsiveHeight={true}."}),t.size&&Array.isArray(t.size)){const[e,o]=t.size;(null!=e&&0>=e||null!=o&&0>=o)&&n.push({severity:"error",code:"BAD_SIZE",message:`size=[${e}, ${o}] — both dimensions must be positive.`,fix:"Set size={[600, 400]}."})}}(0,t,n),function(e,t,n){const o=Bn[e];if(!o||"array"!==o.dataShape)return;const r=t.data;if(!r||!Array.isArray(r)||0===r.length)return;const i=r[0];if(!i||"object"!=typeof i)return;const a=Object.keys(i);for(const e of o.dataAccessors){const o=t[e];"string"==typeof o&&(o in i||n.push({severity:"error",code:"ACCESSOR_MISSING",message:`${e}="${o}" not found in data. Available fields: ${a.join(", ")}.`,fix:`Change ${e} to one of: ${a.map(e=>`"${e}"`).join(", ")}.`}))}}(e,t,n),function(e,t,n){Dn.has(e)&&Array.isArray(t.data)&&n.push({severity:"error",code:"HIERARCHY_FLAT_ARRAY",message:e+" expects hierarchical data but received a flat array.",fix:'Pass a root object: data={{ name: "root", children: [...] }}. For flat data, use BarChart or LineChart.'})}(e,t,n),function(e,t,n){Tn.has(e)&&(t.edges||t.data||n.push({severity:"error",code:"NETWORK_NO_EDGES",message:e+" requires an edges prop.",fix:'Provide edges={[{ source: "A", target: "B", value: 10 }]}.'}))}(e,t,n),function(e,t,n){const o=Bn[e];if(!o||"array"!==o.dataShape)return;const r=t.data;if(!r||!Array.isArray(r)||0===r.length)return;const i=r[0];if(!i||"object"!=typeof i)return;const a=t.xAccessor;"string"==typeof a&&i[a]instanceof Date&&!t.xFormat&&n.push({severity:"warning",code:"DATE_NO_FORMAT",message:`xAccessor "${a}" contains Date objects but no xFormat is provided. Axis ticks may display "[object Object]".`,fix:"Add xFormat={d => d.toLocaleDateString()} or use timestamps (d.getTime()) instead of Date objects."})}(e,t,n),function(e,t,n){t.linkedHover&&!t.selection&&n.push({severity:"warning",code:"LINKED_HOVER_NO_SELECTION",message:"linkedHover is set but selection is not — this chart emits hover events but won't highlight from others.",fix:`Add selection={{ name: "${"object"==typeof t.linkedHover&&t.linkedHover.name||"hl"}" }} to receive cross-highlights.`})}(0,t,n),function(e,t,n){var o;if(!Rn.has(e))return;const r=t.rExtent||t.yExtent;r&&Array.isArray(r)&&r.length>=1&&null!=r[0]&&0!==r[0]&&n.push({severity:"warning",code:"NON_ZERO_BASELINE",message:`${e} has a non-zero baseline (${r[0]}). Bar and area charts should start at zero to avoid exaggerating differences.`,fix:`Remove the custom extent minimum or set it to 0: rExtent={[0, ${null!==(o=r[1])&&void 0!==o?o:"auto"}]}. For trend-focused charts, use LineChart instead.`})}(e,t,n),function(e,t,n){if(!Wn.has(e))return;if(t.gapStrategy)return;const o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;const r=t.yAccessor||"y";"string"==typeof r&&o.some(e=>{const t=e[r];return null==t||Number.isNaN(t)})&&n.push({severity:"warning",code:"DATA_GAPS",message:`Data contains null/undefined/NaN values in "${r}". Default behavior breaks the line at gaps.`,fix:'Set gapStrategy="break" (default), "interpolate", or "zero" to control gap handling.'})}(e,t,n),function(e,t,n){var o,r;const i=null!==(o=t.width)&&void 0!==o?o:600,a=null!==(r=t.height)&&void 0!==r?r:400,s=t.margin;if(!s||"object"!=typeof s)return;const l=(s.left||0)+(s.right||0),c=(s.top||0)+(s.bottom||0);i>l||n.push({severity:"error",code:"MARGIN_OVERFLOW_H",message:`Horizontal margins (${l}px) >= width (${i}px) — no drawing area left.`,fix:"Reduce margin.left/right or increase width."}),a>c||n.push({severity:"error",code:"MARGIN_OVERFLOW_V",message:`Vertical margins (${c}px) >= height (${a}px) — no drawing area left.`,fix:"Reduce margin.top/bottom or increase height."})}(0,t,n),function(e,t,n){var o;const r=Bn[e];if(!r||"array"!==r.dataShape)return;const i=t.data;if(!i||!Array.isArray(i)||0===i.length)return;const a=[];t.xAccessor&&"string"==typeof t.xAccessor&&a.push({prop:"xAccessor",name:t.xAccessor}),t.yAccessor&&"string"==typeof t.yAccessor&&a.push({prop:"yAccessor",name:t.yAccessor}),t.valueAccessor&&"string"==typeof t.valueAccessor&&a.push({prop:"valueAccessor",name:t.valueAccessor});const s=Math.min(i.length,5);for(const e of a){let t=!0;for(let n=0;s>n;n++){const r=null===(o=i[n])||void 0===o?void 0:o[e.name];if("number"==typeof r&&Number.isFinite(r)){t=!1;break}}t&&n.push({severity:"error",code:"DEGENERATE_EXTENT",message:`${e.prop}="${e.name}" produces NaN or non-finite values for all sampled data points — chart extents will be invalid.`,fix:`Ensure data[].${e.name} contains finite numbers, or use a function accessor to transform values.`})}}(e,t,n),function(e,t,n){if(!Fn.has(e))return;const o=t.barPadding;"number"==typeof o&&10>o&&n.push({severity:"warning",code:"BAR_PADDING_INVISIBLE",message:`barPadding=${o} is very small — bars may appear to have no spacing between them.`,fix:"Increase barPadding to at least 10 for visible gaps, e.g. barPadding={12}."})}(e,t,n),function(e,t,n){if("bottom"!==t.legendPosition)return;const o=t.margin;if(!o||"object"!=typeof o)return;const r=o.bottom;"number"==typeof r&&70>r&&n.push({severity:"warning",code:"BOTTOM_MARGIN_WITH_LEGEND",message:`legendPosition="bottom" with margin.bottom=${r}px — legend may overlap axis labels.`,fix:"Increase margin.bottom to at least 70, e.g. margin={{ ...margin, bottom: 80 }}."})}(0,t,n),function(e,t,n){var o;if(!t.showLegend)return;if("right"!==(null!==(o=t.legendPosition)&&void 0!==o?o:"right"))return;const r=t.margin;if(!r||"object"!=typeof r)return;const i=r.right;"number"==typeof i&&100>i&&n.push({severity:"warning",code:"LEGEND_MARGIN_TIGHT",message:`showLegend is true with legendPosition="right" but margin.right=${i}px — legend may be clipped or overlap the chart.`,fix:"Increase margin.right to at least 100, e.g. margin={{ ...margin, right: 120 }}."})}(0,t,n),function(e,t,n){if("Heatmap"!==e)return;const o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;const r=o[0];if(r&&"object"==typeof r)for(const e of["xAccessor","yAccessor"]){const o=t[e];if("string"!=typeof o)continue;const i=r[o];"string"==typeof i&&n.push({severity:"warning",code:"HEATMAP_STRING_ACCESSOR",message:`${e}="${o}" resolves to string values (e.g. "${i}"). Heatmap will use categorical axis handling which may produce unexpected cell layout.`,fix:"If you intend categorical axes this is fine. Otherwise, convert values to numbers before passing data."})}}(e,t,n),function(e,t,n){const o=t.colorScheme;if(!o||!Array.isArray(o))return;const r="string"==typeof t.background?t.background:"#ffffff";if(!r.startsWith("#"))return;const i=[];for(const e of o){if("string"!=typeof e||!e.startsWith("#"))continue;const t=Hn(e,r);null!==t&&3>t&&i.push(`${e} (${t.toFixed(1)}:1)`)}i.length>0&&n.push({severity:"warning",code:"LOW_COLOR_CONTRAST",message:`${i.length} color(s) in colorScheme have < 3:1 contrast against background "${r}": ${i.join(", ")}. Data marks may be hard to see.`,fix:'Use darker colors on light backgrounds or lighter colors on dark backgrounds. Import COLOR_BLIND_SAFE_CATEGORICAL from "semiotic" for an accessible preset.'})}(0,t,n),function(e,t,n){const o=t.colorScheme;if(!o||!Array.isArray(o)||2>o.length)return;const r=o.filter(e=>"string"==typeof e&&e.startsWith("#"));if(2>r.length)return;const i=[];for(let e=0;r.length-1>e;e++){const t=Hn(r[e],r[e+1]);null!==t&&1.5>t&&i.push(`${r[e]} / ${r[e+1]} (${t.toFixed(1)}:1)`)}i.length>0&&n.push({severity:"warning",code:"LOW_ADJACENT_CONTRAST",message:`${i.length} adjacent color pair(s) in colorScheme have very similar luminance: ${i.join("; ")}. Categories may be hard to distinguish.`,fix:'Alternate light and dark colors in the scheme, or use COLOR_BLIND_SAFE_CATEGORICAL from "semiotic" for a pre-tested palette.'})}(0,t,n),function(e,t,n){const o="string"==typeof t.title&&t.title.trim().length>0,r="string"==typeof t.description&&t.description.trim().length>0,i="string"==typeof t.summary&&t.summary.trim().length>0;o||r||i||n.push({severity:"warning",code:"MISSING_DESCRIPTION",message:'No title, description, or summary provided. Screen readers will use a generic label like "XY chart".',fix:'Add a title="..." prop for a brief label, or description="..." for a detailed aria-label, or summary="..." for a screen-reader-only note describing the chart\'s purpose.'})}(0,t,n),function(e,t,n){const o=[];for(const e of qn)"function"==typeof t[e]&&o.push(e);o.length>0&&n.push({severity:"warning",code:"FUNCTION_ACCESSOR",message:`Function accessor${o.length>1?"s":""} detected: ${o.join(", ")}. If defined inline (e.g. \`xAccessor={d => d.value}\`), every parent re-render creates a new reference which may trigger unnecessary scene rebuilds.`,fix:'Use string accessors when possible (e.g. xAccessor="value"), or memoize with useCallback / define outside the component.'})}(0,t,n),{ok:n.every(e=>"warning"===e.severity),diagnoses:n}):{ok:0===n.length,diagnoses:n}}var Vn;const Un="undefined"!=typeof process&&"production"!==(null===(Vn=process.env)||void 0===Vn?void 0:Vn.NODE_ENV);function Zn({componentName:t,width:n,height:o,chartProps:r,children:i}){return e.createElement(En,{fallback:i=>{let a="";if(Un&&r)try{const e=Gn(t,r);e.ok||(a=e.diagnoses.map(e=>`${"error"===e.severity?"✗":"⚠"} ${e.message}${e.fix?" — Fix: "+e.fix:""}`).join("\n"))}catch(e){}return e.createElement(jn,{componentName:t,message:i.message,diagnosticHint:a,width:n,height:o})}},i)}const Yn={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #999)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},Xn={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Kn(t,n,o,r){return!1===r||null==t||Array.isArray(t)&&t.length>0?null:Array.isArray(t)?e.createElement("div",{style:Object.assign(Object.assign({},Yn),{width:n,height:o})},r||"No data available"):null}function Jn(t,n,o){if(!t)return null;const r=Math.min(5,Math.floor(o/40)),i=Math.max(8,Math.floor(o/(3*r))),a=Math.max(6,Math.floor(o/(2.5*r))),s=Math.floor((o-(r*(i+a)-a))/2);return e.createElement("div",{style:{width:n,height:o,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"}},Array.from({length:r},(t,o)=>e.createElement("div",{key:o,className:"semiotic-loading-bar",style:Object.assign(Object.assign({},Xn),{position:"absolute",top:s+o*(i+a),left:Math.floor(.1*n),width:30+(37*o+13)%50+"%",height:i,opacity:.5+o%2*.2})})))}function Qn(e,t,n,o){if(!Un)return;if(!t||0===t.length)return;if("string"!=typeof o)return;const r=t[0];if(!r||"object"!=typeof r)return;if(o in r)return;const i=Object.keys(r).join(", ");console.warn(`[semiotic] ${e}: ${n} "${o}" not found in data. Available keys: ${i}`)}function eo(e,t,n,o){return new(n||(n=Promise))(function(r,i){function a(e){try{l(o.next(e))}catch(e){i(e)}}function s(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}l((o=o.apply(e,t||[])).next())})}function to(e){return e}function no(e,t){var n=t.id,o=t.bbox,r=null==t.properties?{}:t.properties,i=function(e,t){var n=function(e){if(null==e)return to;var t,n,o=e.scale[0],r=e.scale[1],i=e.translate[0],a=e.translate[1];return function(e,s){s||(t=n=0);var l=2,c=e.length,u=Array(c);for(u[0]=(t+=e[0])*o+i,u[1]=(n+=e[1])*r+a;c>l;)u[l]=e[l],++l;return u}}(e.transform),o=e.arcs;function r(e,t){t.length&&t.pop();for(var r=o[0>e?~e:e],i=0,a=r.length;a>i;++i)t.push(n(r[i],i));0>e&&function(e,t){for(var n,o=e.length,r=o-t;r<--o;)n=e[r],e[r++]=e[o],e[o]=n}(t,a)}function i(e){return n(e)}function a(e){for(var t=[],n=0,o=e.length;o>n;++n)r(e[n],t);return 2>t.length&&t.push(t[0]),t}function s(e){for(var t=a(e);4>t.length;)t.push(t[0]);return t}function l(e){return e.map(s)}return function e(t){var n,o=t.type;switch(o){case"GeometryCollection":return{type:o,geometries:t.geometries.map(e)};case"Point":n=i(t.coordinates);break;case"MultiPoint":n=t.coordinates.map(i);break;case"LineString":n=a(t.arcs);break;case"MultiLineString":n=t.arcs.map(a);break;case"Polygon":n=l(t.arcs);break;case"MultiPolygon":n=t.arcs.map(l);break;default:return null}return{type:o,coordinates:n}}(t)}(e,t);return null==n&&null==o?{type:"Feature",properties:r,geometry:i}:null==o?{type:"Feature",id:n,properties:r,geometry:i}:{type:"Feature",id:n,bbox:o,properties:r,geometry:i}}"function"==typeof SuppressedError&&SuppressedError;const oo=new Map;function ro(e){var t;return null!==(t=e.default)&&void 0!==t?t:e}function io(e){return eo(this,void 0,void 0,function*(){const t=oo.get(e);if(t)return t;const{topology:n,objectName:o}=yield function(e){return eo(this,void 0,void 0,function*(){switch(e){case"world-110m":return{topology:ro(yield import("world-atlas/countries-110m.json")),objectName:"countries"};case"world-50m":return{topology:ro(yield import("world-atlas/countries-50m.json")),objectName:"countries"};case"land-110m":return{topology:ro(yield import("world-atlas/land-110m.json")),objectName:"land"};case"land-50m":return{topology:ro(yield import("world-atlas/land-50m.json")),objectName:"land"};default:throw Error(`Unknown reference geography: "${e}". Supported: "world-110m", "world-50m", "land-110m", "land-50m".`)}})}(e);if(!n||!n.objects)throw Error(`resolveReferenceGeography("${e}"): Failed to load topology. Got ${typeof n} with keys: ${n?Object.keys(n).join(", "):"none"}`);const r=function(e,t){return"string"==typeof t&&(t=e.objects[t]),"GeometryCollection"===t.type?{type:"FeatureCollection",features:t.geometries.map(function(t){return no(e,t)})}:no(e,t)}(n,n.objects[o]),i="features"in r?r.features:[r];return oo.set(e,i),i})}function ao(e){const t=r(()=>Array.isArray(e)?e:void 0,[e]),[i,a]=n(null);return o(()=>{if(e&&!Array.isArray(e)){if("string"==typeof(t=e)&&["world-110m","world-50m","land-110m","land-50m"].includes(t)){let t=!1;return a(null),io(e).then(e=>{t||a(e)}),()=>{t=!0}}var t;"production"!==process.env.NODE_ENV&&console.warn(`[semiotic] Unknown areas reference: "${e}". Supported: "world-110m", "world-50m", "land-110m", "land-50m".`),a(null)}else a(null)},[e]),void 0!==t?t:i}const so={blues:K,reds:X,greens:Y,viridis:V};function lo(t){const n=wn(t.mode,{width:t.width,height:t.height,showLegend:t.showLegend,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary}),{areas:o,valueAccessor:i,colorScheme:a="blues",projection:s="equalEarth",graticule:l,fitPadding:c,zoomable:u,zoomExtent:d,onZoom:p,dragRotate:h,tileURL:y,tileAttribution:g,tileCacheSize:f,tooltip:m,areaOpacity:b=1,annotations:v,margin:x,className:k,selection:w,linkedHover:A,onObservation:E,onClick:S,chartId:M,loading:C,emptyContent:$,frameProps:z={}}=t,L=null!=u?u:!!y,P=ao(o),I=r(()=>"function"==typeof i?i:e=>{var t,n;return null!==(n=null===(t=null==e?void 0:e.properties)||void 0===t?void 0:t[i])&&void 0!==n?n:null==e?void 0:e[i]},[i]),B=r(()=>{if(!P)return j(K).domain([0,1]);const e=P.map(e=>I(e)).filter(e=>null!=e&&isFinite(e)),[t,n]=O(e);return j(so[a]||K).domain([null!=t?t:0,null!=n?n:1])},[P,I,a]),{activeSelectionHook:N,customHoverBehavior:D,customClickBehavior:T}=vn({selection:w,linkedHover:A,onObservation:E,onClick:S,chartType:"ChoroplethMap",chartId:M}),R=r(()=>{const e=e=>{const t=I(e);return{fill:null!=t&&isFinite(t)?B(t):"#ccc",stroke:"#999",strokeWidth:.5,fillOpacity:b}};return N?fn(e,N,w):e},[I,B,N,w,b]),W=r(()=>t=>{var n,o;const r=(null===(n=null==t?void 0:t.properties)||void 0===n?void 0:n.name)||(null===(o=null==t?void 0:t.properties)||void 0===o?void 0:o.NAME)||(null==t?void 0:t.name)||(null==t?void 0:t.NAME)||"Feature",i=I(t);return e.createElement("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12}},e.createElement("div",{style:{fontWeight:600}},r),null!=i&&e.createElement("div",{style:{opacity:.7}},"number"==typeof(a=i)&&isFinite(a)?Number.isInteger(a)?a.toLocaleString():a.toLocaleString(void 0,{maximumFractionDigits:2}):(null!=a?a:"")+""));var a},[I]),F=r(()=>Object.assign({top:10,right:10,bottom:10,left:10},x),[x]),_=Jn(C,n.width,n.height)||(P?null:Jn(!0,n.width,n.height)),H=_?null:Kn(P,n.width,n.height,$);if(Array.isArray(P)&&P.length>0){const t=P[0];if(!t||"object"!=typeof t||!t.geometry)return e.createElement(jn,{componentName:"ChoroplethMap",message:"ChoroplethMap: areas must be an array of GeoJSON Features with a geometry property.",width:n.width,height:n.height})}const q=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({projection:s,areas:P,areaStyle:R,size:[n.width,n.height],margin:F,enableHover:!0,tooltipContent:!1===m?()=>null:!0===m?W:Xt(m)||W},null!=l&&{graticule:l}),null!=c&&{fitPadding:c}),L&&{zoomable:!0}),d&&{zoomExtent:d}),p&&{onZoom:p}),null!=h&&{dragRotate:h}),y&&{tileURL:y}),g&&{tileAttribution:g}),f&&{tileCacheSize:f}),(A||E||S)&&{customHoverBehavior:D}),(E||S)&&{customClickBehavior:T}),v&&v.length>0&&{annotations:v}),n.title&&{title:n.title}),n.description&&{description:n.description}),n.summary&&{summary:n.summary}),void 0!==n.accessibleTable&&{accessibleTable:n.accessibleTable}),k&&{className:k}),z);return _||H||e.createElement(Zn,{componentName:"ChoroplethMap",width:n.width,height:n.height},e.createElement(Gt,Object.assign({},q)))}lo.displayName="ChoroplethMap";const co=c(function(o,i){const a=t(null);u(i,()=>({push:e=>{var t;return null===(t=a.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=a.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=a.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=a.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const s=wn(o.mode,{width:o.width,height:o.height,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary}),{points:c,xAccessor:d="lon",yAccessor:p="lat",sizeBy:h,sizeRange:y=[3,30],colorBy:g,colorScheme:f,projection:m="equalEarth",graticule:b,fitPadding:v,zoomable:x,zoomExtent:k,onZoom:w,dragRotate:A,tileURL:j,tileAttribution:E,tileCacheSize:O,areas:S,areaStyle:M={fill:"#f0f0f0",stroke:"#ccc",strokeWidth:.5},tooltip:C,annotations:$,margin:z,className:L,selection:P,linkedHover:I,onObservation:B,onClick:N,chartId:D,loading:T,emptyContent:R,legendInteraction:W,legendPosition:F,frameProps:_={}}=o,H=null!=x?x:!!j,q=ao(S),G=c||[],{activeSelectionHook:V,customHoverBehavior:U,customClickBehavior:Z}=vn({selection:P,linkedHover:I,fallbackFields:g?["string"==typeof g?g:""]:[],onObservation:B,onClick:N,chartType:"ProportionalSymbolMap",chartId:D}),Y=bn(G,g,f),X=r(()=>{if(!h)return;const e="function"==typeof h?h:e=>e[h],t=G.map(t=>e(t)).filter(e=>null!=e&&isFinite(e));return 0!==t.length?[Math.min(...t),Math.max(...t)]:void 0},[G,h]),K=r(()=>{const e=e=>({fill:g?tn(e,g,Y):mn,fillOpacity:.7,stroke:"#fff",strokeWidth:.5,r:h?on(e,h,y,X):6});return V?fn(e,V,P):e},[g,Y,h,y,X,V,P]),J=r(()=>{if(!g)return[];const e="function"==typeof g?g:e=>e[g],t=new Set;for(const n of G){const o=e(n);null!=o&&t.add(o+"")}return Array.from(t)},[G,g]),Q=function(e,t,o){const[i,a]=n(null),[s,c]=n(new Set),u=l(t=>{"highlight"===e&&a(t?t.label:null)},[e]),d=l(t=>{"isolate"===e&&c(e=>{const n=new Set(e);return n.has(t.label)?n.delete(t.label):n.add(t.label),n.size===o.length?new Set:n})},[e,o.length]),p=r(()=>{if(!e||"none"===e||!t)return null;const n="string"==typeof t?t:null;return"highlight"===e&&null!=i?{isActive:!0,predicate:e=>(n?e[n]:"function"==typeof t?t(e):null)===i}:"isolate"===e&&s.size>0?{isActive:!0,predicate:e=>{const o=n?e[n]:"function"==typeof t?t(e):null;return s.has(o)}}:null},[e,t,i,s]);return{highlightedCategory:"highlight"===e?i:null,isolatedCategories:"isolate"===e?s:new Set,onLegendHover:u,onLegendClick:d,legendSelectionHook:p}}(W,g,J),{legend:ee,margin:te,legendPosition:ne}=xn({data:G,colorBy:g,colorScale:Y,showLegend:s.showLegend,legendPosition:F,userMargin:z,defaults:{top:10,bottom:10,left:10,right:10}}),oe=r(()=>t=>{const n=(null==t?void 0:t.name)||(null==t?void 0:t.label)||(null==t?void 0:t.NAME)||(null==t?void 0:t.id),o="string"==typeof h?h:null,r=("function"==typeof h?h:e=>e[h])(t),i=e=>"number"==typeof e&&isFinite(e)?Number.isInteger(e)?e.toLocaleString():e.toLocaleString(void 0,{maximumFractionDigits:2}):(null!=e?e:"")+"",a="string"==typeof g?g:null,s=a?null==t?void 0:t[a]:null;return e.createElement("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12}},n&&e.createElement("div",{style:{fontWeight:600,marginBottom:2}},n),o&&null!=r&&e.createElement("div",null,e.createElement("span",{style:{opacity:.7}},o,": "),i(r)),a&&null!=s&&e.createElement("div",null,e.createElement("span",{style:{opacity:.7}},a,": "),s+""),!n&&!o&&Object.entries(t).filter(([e])=>"data"!==e&&"x"!==e&&"y"!==e&&"time"!==e).slice(0,4).map(([t,n])=>e.createElement("div",{key:t},e.createElement("span",{style:{opacity:.7}},t,": "),i(n))))},[h,g]),re=Jn(T,s.width,s.height),ie=re?null:Kn(c,s.width,s.height,R);Qn("ProportionalSymbolMap",G,"xAccessor",d),Qn("ProportionalSymbolMap",G,"yAccessor",p);const ae=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({projection:m},null!=c&&{points:G}),{xAccessor:d,yAccessor:p,pointStyle:K}),q&&{areas:q,areaStyle:M}),null!=b&&{graticule:b}),null!=v&&{fitPadding:v}),H&&{zoomable:!0}),k&&{zoomExtent:k}),w&&{onZoom:w}),null!=A&&{dragRotate:A}),j&&{tileURL:j}),E&&{tileAttribution:E}),O&&{tileCacheSize:O}),{size:[s.width,s.height],margin:te,enableHover:!0,tooltipContent:!1===C?()=>null:Xt(C)||oe}),ee&&{legend:ee,legendPosition:ne}),W&&"none"!==W&&{legendHoverBehavior:Q.onLegendHover,legendClickBehavior:Q.onLegendClick,legendHighlightedCategory:Q.highlightedCategory,legendIsolatedCategories:Q.isolatedCategories}),(I||B||N)&&{customHoverBehavior:U}),(B||N)&&{customClickBehavior:Z}),$&&$.length>0&&{annotations:$}),s.title&&{title:s.title}),s.description&&{description:s.description}),s.summary&&{summary:s.summary}),void 0!==s.accessibleTable&&{accessibleTable:s.accessibleTable}),L&&{className:L}),_);return re||ie||e.createElement(Zn,{componentName:"ProportionalSymbolMap",width:s.width,height:s.height},e.createElement(Gt,Object.assign({ref:a},ae)))});function uo(t){const n=wn(t.mode,{width:t.width,height:t.height,showLegend:t.showLegend,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary}),{flows:o,nodes:i,nodeIdAccessor:a="id",xAccessor:s="lon",yAccessor:c="lat",valueAccessor:u="value",projection:d="equalEarth",graticule:p,fitPadding:h,zoomable:y,zoomExtent:g,onZoom:f,dragRotate:m,tileURL:b,tileAttribution:v,tileCacheSize:x,lineType:k="geo",flowStyle:A="basic",areas:j,areaStyle:E={fill:"#f0f0f0",stroke:"#ccc",strokeWidth:.5},edgeColorBy:O,edgeOpacity:S=.6,edgeWidthRange:M=[1,8],edgeLinecap:C="round",colorScheme:$,showParticles:z,particleStyle:L,tooltip:P,annotations:I,margin:B,className:N,selection:D,linkedHover:T,onObservation:R,onClick:W,chartId:F,loading:_,emptyContent:H,frameProps:q={}}=t,G=null!=y?y:!!b,V=ao(j),U=gn(T),Z=pn({name:(null==D?void 0:D.name)||"__unused__"}),Y=hn({name:(null==U?void 0:U.name)||"hover",fields:(null==U?void 0:U.fields)||[]}),X=dn(e=>e.pushObservation),K=D?{isActive:Z.isActive,predicate:Z.predicate}:null,J=o||[],Q=i||[],ee=bn(J,O,$),te=r(()=>{const e=new Map;for(const t of Q)e.set(t[a]+"",t);return e},[Q,a]),ne=r(()=>{const e=new Map;for(const t of J)t&&"object"==typeof t&&(null==t.source||e.has(t.source)||e.set(t.source,t),null==t.target||e.has(t.target)||e.set(t.target,t));return e},[J]),oe=l(e=>{var t,n;if(T)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"point"===e.type){const e=ne.get(t[a]+"");e&&Y.onHover(e)}else Y.onHover(t)}else Y.onHover(null);if(R||X){const o={timestamp:Date.now(),chartType:"FlowMap",chartId:F};if(e){let r=e.data||e.datum||e;Array.isArray(r)&&(r=r[0]);const i=Object.assign(Object.assign({},o),{type:"hover",datum:r||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0});R&&R(i),X&&X(i)}else{const e=Object.assign(Object.assign({},o),{type:"hover-end"});R&&R(e),X&&X(e)}}},[T,Y,a,ne,R,F,X]),re=l(e=>{var t,n,o,r;if(e&&W){let o=e.data||e.datum||e;Array.isArray(o)&&(o=o[0]),W(o,{x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0})}if(e&&(R||X)){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n={timestamp:Date.now(),chartType:"FlowMap",chartId:F,type:"click",datum:t||{},x:null!==(o=e.x)&&void 0!==o?o:0,y:null!==(r=e.y)&&void 0!==r?r:0};R&&R(n),X&&X(n)}},[W,R,X,F]),ie=r(()=>{const e="function"==typeof s?s:e=>e[s],t="function"==typeof c?c:e=>e[c];return J.map(n=>{if(!n||"object"!=typeof n||null==n.source||null==n.target)return null;const o=te.get(n.source+""),r=te.get(n.target+"");return o&&r?Object.assign(Object.assign({},n),{coordinates:[{[s]:e(o),[c]:t(o)},{[s]:e(r),[c]:t(r)}]}):null}).filter(Boolean)},[J,te,s,c]),ae=r(()=>{const e=J.filter(e=>e&&"object"==typeof e).map(e=>{var t;return null!==(t=e[u])&&void 0!==t?t:0}).filter(e=>isFinite(e));return 0===e.length?()=>M[0]:w().domain([Math.min(...e),Math.max(...e)]).range(M)},[J,u,M]),se=r(()=>e=>{var t;return{stroke:O?tn(e,O,ee):mn,strokeWidth:ae(null!==(t=e[u])&&void 0!==t?t:0),strokeLinecap:C,opacity:S}},[O,ee,ae,u,S,C]),le=r(()=>K?fn(se,K,Object.assign(Object.assign({},D||{}),{unselectedStyle:{opacity:.15,strokeOpacity:.15,fillOpacity:0}})):se,[se,K,D]),ce=r(()=>()=>({fill:"#333",r:5,fillOpacity:.8}),[]),ue=r(()=>t=>{var n,o,r,i,s,l,c;if((null==t?void 0:t.geometry)||(null==t?void 0:t.properties)||(null===(n=null==t?void 0:t.data)||void 0===n?void 0:n.geometry)){const n=(null===(o=null==t?void 0:t.properties)||void 0===o?void 0:o.name)||(null===(r=null==t?void 0:t.properties)||void 0===r?void 0:r.NAME)||(null==t?void 0:t.name)||(null==t?void 0:t.NAME)||(null===(s=null===(i=null==t?void 0:t.data)||void 0===i?void 0:i.properties)||void 0===s?void 0:s.name)||(null===(c=null===(l=null==t?void 0:t.data)||void 0===l?void 0:l.properties)||void 0===c?void 0:c.NAME);if(n)return e.createElement("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12}},e.createElement("div",{style:{fontWeight:600}},n))}if(null!=(null==t?void 0:t.source)&&null!=(null==t?void 0:t.target)){const n=t[u];return e.createElement("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12}},e.createElement("div",{style:{fontWeight:600}},t.source," → ",t.target),null!=n&&e.createElement("div",{style:{opacity:.7}},"number"==typeof n?n.toLocaleString():n))}const d=(null==t?void 0:t.name)||(null==t?void 0:t.label)||(null==t?void 0:t[a]);return null!=d?e.createElement("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12}},e.createElement("div",{style:{fontWeight:600}},d)):null},[u,a]),de=r(()=>Object.assign({top:10,right:10,bottom:10,left:10},B),[B]),pe=Jn(_,n.width,n.height),he=pe?null:Kn(o,n.width,n.height,H),ye=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({projection:d,lines:ie,points:Q,xAccessor:s,yAccessor:c,lineDataAccessor:"coordinates",lineType:k,flowStyle:A,lineStyle:le,pointStyle:ce},V&&{areas:V,areaStyle:E}),null!=p&&{graticule:p}),null!=h&&{fitPadding:h}),G&&{zoomable:!0}),g&&{zoomExtent:g}),f&&{onZoom:f}),null!=m&&{dragRotate:m}),z&&{showParticles:z}),L&&{particleStyle:L}),b&&{tileURL:b}),v&&{tileAttribution:v}),x&&{tileCacheSize:x}),{size:[n.width,n.height],margin:de,enableHover:!0,tooltipContent:!1===P?()=>null:Xt(P)||ue}),(T||R||W)&&{customHoverBehavior:oe}),(R||W)&&{customClickBehavior:re}),I&&I.length>0&&{annotations:I}),n.title&&{title:n.title}),n.description&&{description:n.description}),n.summary&&{summary:n.summary}),void 0!==n.accessibleTable&&{accessibleTable:n.accessibleTable}),N&&{className:N}),q);return pe||he||e.createElement(Zn,{componentName:"FlowMap",width:n.width,height:n.height},e.createElement(Gt,Object.assign({},ye)))}co.displayName="ProportionalSymbolMap",uo.displayName="FlowMap";const po=c(function(i,a){const s=wn(i.mode,{width:i.width,height:i.height,showLegend:i.showLegend,title:i.title,description:i.description,accessibleTable:i.accessibleTable,summary:i.summary}),{points:c,lines:d,xAccessor:p="lon",yAccessor:h="lat",nodeIdAccessor:y="id",center:g,costAccessor:f,strength:m=1,lineMode:b="straight",projection:v="mercator",graticule:x,fitPadding:k,zoomable:w,zoomExtent:A,onZoom:j,dragRotate:E,tileURL:O,tileAttribution:S,tileCacheSize:M,transition:C,colorBy:$,colorScheme:z,pointRadius:L=5,tooltip:P,showRings:I=!0,ringStyle:B,showNorth:N=!0,costLabel:D,annotations:T,margin:R,className:W,selection:F,linkedHover:_,onObservation:H,onClick:q,chartId:G,loading:V,emptyContent:U,legendPosition:Z,frameProps:Y={}}=i,X=null!=w?w:!!O,K=c||[],{activeSelectionHook:J,customHoverBehavior:Q,customClickBehavior:ee}=vn({selection:F,linkedHover:_,fallbackFields:$?["string"==typeof $?$:""]:[],onObservation:H,onClick:q,chartType:"DistanceCartogram",chartId:G}),te=bn(K,$,z),ne=r(()=>{const e=e=>({fill:$?tn(e,$,te):mn,fillOpacity:.8,stroke:"#fff",strokeWidth:1,r:L});return J?fn(e,J,F):e},[$,te,L,J,F]),{legend:oe,margin:re,legendPosition:ie}=xn({data:K,colorBy:$,colorScale:te,showLegend:s.showLegend,legendPosition:Z,userMargin:R,defaults:{top:10,bottom:10,left:10,right:10}}),ae=r(()=>({center:g,centerAccessor:y,costAccessor:f,strength:m,lineMode:b}),[g,y,f,m,b]),se=r(()=>{if(!d)return;const e="function"==typeof p?p:e=>e[p],t="function"==typeof h?h:e=>e[h],n=new Map;for(const e of K)n.set(e[y]+"",e);return d.map(o=>{if(o.coordinates)return o;const r=n.get(o.source+""),i=n.get(o.target+"");return r&&i?Object.assign(Object.assign({},o),{coordinates:[{[p]:e(r),[h]:t(r)},{[p]:e(i),[h]:t(i)}]}):null}).filter(Boolean)},[d,K,p,h,y]),le=r(()=>t=>{const n=("function"==typeof f?f:e=>e[f])(t);return e.createElement("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12}},e.createElement("div",{style:{fontWeight:600}},t[y]||t.name||t.id||"Point"),null!=n&&e.createElement("div",{style:{opacity:.7}},"Cost: ","number"==typeof n?n.toFixed(1):n))},[f,y]),ce=t(null);u(a,()=>({push:e=>{var t;return null===(t=ce.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=ce.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=ce.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=ce.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const[ue,de]=n(null),pe=l(()=>{var e,t;const n=null===(t=null===(e=ce.current)||void 0===e?void 0:e.getCartogramLayout)||void 0===t?void 0:t.call(e);n&&de(e=>e&&e.cx===n.cx&&e.cy===n.cy&&e.maxCost===n.maxCost&&e.availableRadius===n.availableRadius?e:n)},[]);o(()=>{const e=requestAnimationFrame(pe);return()=>cancelAnimationFrame(e)},[pe,m,g,s.width,s.height,K]);const he=r(()=>{if(!I||!ue)return[];const{maxCost:e}=ue;if(0>=e)return[];if(Array.isArray(I))return I.filter(t=>t>0&&e>=t);const t="number"==typeof I?I:Math.min(5,Math.max(2,Math.ceil(e/5))),n=e/t,o=[];for(let e=1;t>=e;e++)o.push(Math.round(n*e*10)/10);return o},[I,ue]),ye=r(()=>{var t,n;if(!ue)return Y.foregroundGraphics||null;const{cx:o,cy:r,maxCost:i,availableRadius:a}=ue,s=Object.assign({stroke:"#999",strokeWidth:.8,strokeDasharray:"4,3",labelColor:"#777",labelSize:10},B),l=null!==(t=re.left)&&void 0!==t?t:10,c=null!==(n=re.top)&&void 0!==n?n:10;return e.createElement("g",null,he.map(t=>{const n=t/i*a;return e.createElement("g",{key:t},e.createElement("circle",{cx:o+l,cy:r+c,r:n,fill:"none",stroke:s.stroke,strokeWidth:s.strokeWidth,strokeDasharray:s.strokeDasharray,opacity:.5}),e.createElement("text",{x:o+l+n+3,y:r+c-2,fontSize:s.labelSize,fill:s.labelColor,fontFamily:"system-ui, sans-serif"},t,D?" "+D:""))}),N&&e.createElement("g",{transform:`translate(${l+24}, ${c+24})`},e.createElement("circle",{r:16,fill:"white",fillOpacity:.85,stroke:"#bbb",strokeWidth:.8}),e.createElement("path",{d:"M0,-11 L3,-3 L1,-4 L1,7 L-1,7 L-1,-4 L-3,-3 Z",fill:"#555",stroke:"none"}),e.createElement("text",{y:-12,textAnchor:"middle",fontSize:7,fontWeight:700,fill:"#555",fontFamily:"system-ui, sans-serif"},"N"),e.createElement("line",{x1:11,y1:0,x2:13,y2:0,stroke:"#bbb",strokeWidth:.8}),e.createElement("line",{x1:-11,y1:0,x2:-13,y2:0,stroke:"#bbb",strokeWidth:.8}),e.createElement("line",{x1:0,y1:11,x2:0,y2:13,stroke:"#bbb",strokeWidth:.8})),Y.foregroundGraphics)},[ue,he,N,D,B,re,Y.foregroundGraphics]),ge=Jn(V,s.width,s.height),fe=ge?null:Kn(c,s.width,s.height,U);Qn("DistanceCartogram",K,"xAccessor",p),Qn("DistanceCartogram",K,"yAccessor",h);const me=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({projection:v},null!=c&&{points:K}),se&&{lines:se,lineDataAccessor:"coordinates"}),{xAccessor:p,yAccessor:h,pointIdAccessor:y,pointStyle:ne,projectionTransform:ae}),C&&{transition:{duration:C}}),null!=x&&{graticule:x}),null!=k&&{fitPadding:k}),X&&{zoomable:!0}),A&&{zoomExtent:A}),j&&{onZoom:j}),null!=E&&{dragRotate:E}),O&&{tileURL:O}),S&&{tileAttribution:S}),M&&{tileCacheSize:M}),{size:[s.width,s.height],margin:re,enableHover:!0,tooltipContent:!1===P?()=>null:Xt(P)||le}),oe&&{legend:oe,legendPosition:ie}),(_||H||q)&&{customHoverBehavior:Q}),(H||q)&&{customClickBehavior:ee}),T&&T.length>0&&{annotations:T}),s.title&&{title:s.title}),s.description&&{description:s.description}),s.summary&&{summary:s.summary}),void 0!==s.accessibleTable&&{accessibleTable:s.accessibleTable}),W&&{className:W}),Y),ye&&{foregroundGraphics:ye});return ge||fe||e.createElement(Zn,{componentName:"DistanceCartogram",width:s.width,height:s.height},e.createElement(Gt,Object.assign({ref:ce},me)))});function ho(e,t,n){const{featureKey:o,dataKey:r}=n,i=new Map;for(const e of t)i.set(e[r]+"",e);return e.map(e=>{const t=(e=>{const t=o.split(".");let n=e;for(const e of t)n=null==n?void 0:n[e];return(null!=n?n:"")+""})(e),n=i.get(t);return n?Object.assign(Object.assign({},e),{properties:Object.assign(Object.assign({},e.properties),n)}):e})}po.displayName="DistanceCartogram";export{lo as ChoroplethMap,po as DistanceCartogram,uo as FlowMap,co as ProportionalSymbolMap,Gt as StreamGeoFrame,ho as mergeData,io as resolveReferenceGeography};
1
+ import*as e from"react";import{useRef as t,useState as n,useEffect as o,useMemo as r,useSyncExternalStore as i,createContext as a,useContext as s,useCallback as l,forwardRef as c,useImperativeHandle as u,useId as d}from"react";import{geoPath as p,geoGraticule as h,geoDistance as y,geoInterpolate as f,geoEqualEarth as g,geoEquirectangular as m,geoNaturalEarth1 as b,geoOrthographic as v,geoAlbersUsa as x,geoMercator as k}from"d3-geo";import{scaleLinear as w,scaleOrdinal as A,scaleSequential as j}from"d3-scale";import{bin as E,extent as O}from"d3-array";import{packEnclose as S}from"d3-hierarchy";import{area as M,curveCatmullRom as C,curveCardinal as $,curveBasis as z,curveStepBefore as L,curveStepAfter as P,curveStep as B,curveMonotoneY as I,curveMonotoneX as N,curveLinear as D,line as T,curveNatural as R}from"d3-shape";import W from"regression";import{zoomIdentity as _,zoom as F}from"d3-zoom";import{select as H}from"d3-selection";import{schemeCategory10 as q,interpolatePlasma as G,interpolateViridis as V,interpolatePurples as U,interpolateOranges as Z,interpolateGreens as Y,interpolateReds as X,interpolateBlues as K,schemeSet3 as J,schemeTableau10 as Q}from"d3-scale-chromatic";class ee{constructor(e){if(this._capacity=e,this.head=0,this._size=0,1>e)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(e)}push(e){let t;return this._size===this._capacity?t=this.buffer[this.head]:this._size++,this.buffer[this.head]=e,this.head=(this.head+1)%this._capacity,t}pushMany(e){const t=[];for(const n of e){const e=this.push(n);void 0!==e&&t.push(e)}return t}get(e){if(e>=0&&this._size>e)return this.buffer[(this.head-this._size+e+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let e=0;const t=this;return{next:()=>t._size>e?{done:!1,value:t.get(e++)}:{done:!0,value:void 0}}}forEach(e){const t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e(this.buffer[(t+n)%this._capacity],n)}toArray(){const e=Array(this._size),t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e[n]=this.buffer[(t+n)%this._capacity];return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray(),n=[];for(;t.length>e;)n.push(t.shift());this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(const e of t)this.push(e);return n}update(e,t){const n=[],o=(this.head-this._size+this._capacity)%this._capacity;for(let r=0;this._size>r;r++){const i=(o+r)%this._capacity,a=this.buffer[i];if(e(a)){let e;e="object"!=typeof a||null===a?a:Array.isArray(a)?[...a]:Object.assign({},a),n.push(e),this.buffer[i]=t(a)}}return n}remove(e){const t=[],n=[];if(this.forEach(o=>{e(o)?n.push(o):t.push(o)}),0===n.length)return n;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const e of t)this.push(e);return n}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}}function te(e,t,n){return e+(t-e)*n}const ne={mercator:k,equalEarth:g,albersUsa:x,orthographic:v,naturalEarth:b,equirectangular:m};function oe(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}function re(e){return e?"function"==typeof e?e:t=>t[e]:e=>e.coordinates||e.data||[]}function ie(e,t,n){return e?Object.assign(Object.assign({},n),"function"==typeof e?e(t):e):n}const ae={fill:"#e0e0e0",stroke:"#999",strokeWidth:.5,fillOpacity:1},se={fill:"#4e79a7",r:4,fillOpacity:.8},le={stroke:"#4e79a7",strokeWidth:1.5,fill:"none"};function ce(e,t){if(2>e.length)return[e];const n=.4*t,o=[];let r=[e[0]];for(let t=1;e.length>t;t++){const i=e[t];Math.abs(i[0]-e[t-1][0])>n?(2>r.length||o.push(r),r=[i]):r.push(i)}return 2>r.length||o.push(r),o}function ue(e,t,n=24){const o=t[0]-e[0],r=t[1]-e[1],i=Math.sqrt(o*o+r*r);if(0===i)return[e,t];const a=-r/i,s=o/i,l=Math.min(.3*i,80),c=(e[0]+t[0])/2+a*l,u=(e[1]+t[1])/2+s*l,d=[];for(let o=0;n>=o;o++){const r=o/n,i=1-r;d.push([i*i*e[0]+2*i*r*c+r*r*t[0],i*i*e[1]+2*i*r*u+r*r*t[1]])}return d}function de(e,t){if(2>e.length)return e;const n=t/2+1,o=[];for(let t=0;e.length>t;t++){const r=e[t];let i,a;0===t?(i=e[1][0]-r[0],a=e[1][1]-r[1]):t===e.length-1?(i=r[0]-e[t-1][0],a=r[1]-e[t-1][1]):(i=e[t+1][0]-e[t-1][0],a=e[t+1][1]-e[t-1][1]);const s=Math.sqrt(i*i+a*a)||1;o.push([r[0]+a/s*n,r[1]+-i/s*n])}return o}function pe(e,t,n,o,r){const i=t[0]-e[0],a=t[1]-e[1],s=Math.sqrt(i*i+a*a);if(0===s)return[e,t];const l=a/s,c=-i/s,u=r/2+1;return[[e[0]+l*u,e[1]+c*u],[t[0]+l*u,t[1]+c*u]]}class he{constructor(e){this.scene=[],this.scales=null,this.version=0,this.projection=null,this.geoPath=null,this.baseScale=0,this.baseTranslate=[0,0],this.baseRotation=[0,0,0],this.currentZoom=1,this.cartogramLayout=null,this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.streaming=!1,this.lastIngestTime=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositions=null,this.config=e}updateConfig(e){this.config=Object.assign(Object.assign({},this.config),e)}setAreas(e){this.areas=e}setPoints(e){this.pointData=e,this.streaming=!1}setLines(e){this.lineData=e}initStreaming(e=500){this.pointBuffer=new ee(e),this.timestampBuffer=new ee(e),this.streaming=!0}pushPoint(e){this.pointBuffer||this.initStreaming(),this.pointBuffer.push(e),this.timestampBuffer.push(performance.now()),this.lastIngestTime=performance.now()}pushMany(e){this.pointBuffer||this.initStreaming();const t=performance.now();for(const n of e)this.pointBuffer.push(n),this.timestampBuffer.push(t);this.lastIngestTime=t}removePoint(e){const{pointIdAccessor:t}=this.config;if(!t)throw Error("removePoint() requires pointIdAccessor to be configured");const n="function"==typeof t?t:e=>e[t],o=new Set(Array.isArray(e)?e:[e]);if(this.streaming&&this.pointBuffer){const e=e=>o.has(n(e)+"");if(this.timestampBuffer&&this.timestampBuffer.size>0){const t=this.timestampBuffer.toArray(),n=new Set;this.pointBuffer.forEach((t,o)=>{e(t)&&n.add(o)}),this.timestampBuffer.clear();for(let e=0;t.length>e;e++)n.has(e)||this.timestampBuffer.push(t[e])}const t=this.pointBuffer.remove(e);return t.length>0&&this.version++,t}{const e=[];return this.pointData=this.pointData.filter(t=>!o.has(n(t)+"")||(e.push(t),!1)),e.length>0&&this.version++,e}}clear(){this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.timestampBuffer=null,this.scene=[],this.scales=null,this.version++}computeScene(e){const{config:t}=this;this.projection=function(e){if(!e)return g();if("string"==typeof e){const t=ne[e];return t?t():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${e}", falling back to equalEarth`),g())}if("object"==typeof e&&"type"in e){const t=ne[e.type],n=t?t():g();return e.rotate&&"rotate"in n&&n.rotate(e.rotate),e.center&&"center"in n&&n.center(e.center),n}return e}(t.projection),this.geoPath=p(this.projection),this.fitProjection(e),this.geoPath=p(this.projection);const n=this.projection;this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(e,t)=>n([e,t]),invertedPoint:(e,t)=>n.invert?n.invert([e,t]):null};const o=this.scene;this.scene=this.buildSceneNodes(e),t.projectionTransform&&this.applyCartogramTransform(t.projectionTransform,e),t.decay&&this.streaming&&this.applyDecay(),t.pulse&&this.streaming&&this.applyPulse(),t.transition&&o.length>0&&this.startTransition(o),this.version++}fitProjection(e){var t,n,o,r,i;const a=this.projection,s=this.config,l=[...this.areas],c=oe(s.xAccessor,"lon"),u=oe(s.yAccessor,"lat"),d=this.getPoints();if(d.length>0){const e=d.map(e=>[c(e),u(e)]);l.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:e}})}const p=re(s.lineDataAccessor);for(const e of this.lineData){const t=p(e);if(t&&t.length>0){const e=t.map(e=>[c(e),u(e)]);l.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:e}})}}if(0!==l.length){if(s.projectionExtent){const[[t,n],[o,r]]=s.projectionExtent;a.fitExtent([[0,0],[e.width,e.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[t,n],[o,n],[o,r],[t,r],[t,n]]]}})}else if(a.clipAngle&&(null!==(t=a.clipAngle())&&void 0!==t?t:0)>0){const t=null!==(n=s.fitPadding)&&void 0!==n?n:0,o=Math.min(e.width,e.height);a.scale(o/2-o*t),a.translate([e.width/2,e.height/2])}else{const t=null!==(o=s.fitPadding)&&void 0!==o?o:0,n=e.width*t,r=e.height*t;a.fitExtent([[n,r],[e.width-n,e.height-r]],{type:"FeatureCollection",features:l})}this.baseScale=a.scale(),this.baseTranslate=a.translate(),this.baseRotation=null!==(i=null===(r=a.rotate)||void 0===r?void 0:r.call(a))&&void 0!==i?i:[0,0,0]}}applyZoomTransform(e,t){const n=this.projection;n&&(n.scale(this.baseScale*e.k),n.translate([this.baseTranslate[0]*e.k+e.x,this.baseTranslate[1]*e.k+e.y]),this.currentZoom=e.k,this.geoPath=p(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(e,t)=>n([e,t]),invertedPoint:(e,t)=>n.invert?n.invert([e,t]):null},this.scene=this.buildSceneNodes(t),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}applyZoomScale(e,t){const n=this.projection;n&&(n.scale(this.baseScale*e),n.translate(this.baseTranslate),this.currentZoom=e,this.geoPath=p(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(e,t)=>n([e,t]),invertedPoint:(e,t)=>n.invert?n.invert([e,t]):null},this.scene=this.buildSceneNodes(t),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}applyRotation(e,t){const n=this.projection;n&&n.rotate&&(n.rotate(e),this.geoPath=p(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(e,t)=>n([e,t]),invertedPoint:(e,t)=>n.invert?n.invert([e,t]):null},this.scene=this.buildSceneNodes(t),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}setRotation(e){const t=this.projection;t&&t.rotate&&t.rotate(e)}getRotation(){var e,t,n;return null!==(n=null===(t=null===(e=this.projection)||void 0===e?void 0:e.rotate)||void 0===t?void 0:t.call(e))&&void 0!==n?n:this.baseRotation}getBaseProjectionState(){return{scale:this.baseScale,translate:[...this.baseTranslate]}}getPoints(){return this.streaming&&this.pointBuffer?this.pointBuffer.toArray():this.pointData}buildSceneNodes(e){var t,n,o;const r=[],{config:i}=this,a=this.projection,s=this.geoPath,l=oe(i.xAccessor,"lon"),c=oe(i.yAccessor,"lat");if(i.graticule){const t=!0===i.graticule?{}:i.graticule,n=h();t.step&&n.step(t.step);const o=s(n())||"";o&&r.push({type:"geoarea",pathData:o,centroid:[e.width/2,e.height/2],bounds:[[0,0],[e.width,e.height]],screenArea:0,style:{fill:"none",stroke:t.stroke||"#e0e0e0",strokeWidth:t.strokeWidth||.5,strokeDasharray:t.strokeDasharray||"2,2"},datum:null,interactive:!1})}for(const e of this.areas){const t=s(e);if(!t)continue;const n=s.centroid(e),o=s.bounds(e),a=s.area(e),l=ie(i.areaStyle,e,ae);r.push({type:"geoarea",pathData:t,centroid:n,bounds:o,screenArea:a,style:l,datum:e,interactive:!0})}const u=re(i.lineDataAccessor);for(const t of this.lineData){const n=u(t);if(!n||2>n.length)continue;const o=n.map(e=>[l(e),c(e)]);let s;if("geo"===i.lineType){const e=[];for(let t=0;o.length-1>t;t++){const n=o[t],r=o[t+1],i=y(n,r)||0,a=Math.max(2,Math.ceil(i/(Math.PI/180))),s=f(n,r);for(let n=0;a>=n;n++)t>0&&0===n||e.push(s(n/a))}s=e.map(([e,t])=>a([e,t])).filter(e=>null!=e)}else s=o.map(([e,t])=>a([e,t])).filter(e=>null!=e);if(2>s.length)continue;const d=ie(i.lineStyle,t,le),p="number"==typeof d.strokeWidth?d.strokeWidth:1;2!==o.length||2>s.length||"arc"!==i.flowStyle?2!==o.length||2>s.length||"offset"!==i.flowStyle||(s="geo"===i.lineType?de(s,p):pe(s[0],s[s.length-1],0,0,p)):s=ue(s[0],s[s.length-1]);const h=ce(s,e.width);if(h.length>1)for(const e of h){if(2>e.length)continue;const n={type:"line",path:e,style:Object.assign(Object.assign({},d),{_edgeFade:!0}),datum:t};r.push(n)}else r.push({type:"line",path:2>s.length&&h[0]||s,style:d,datum:t})}const d=this.getPoints(),p=i.pointIdAccessor?"function"==typeof i.pointIdAccessor?i.pointIdAccessor:e=>e[i.pointIdAccessor]:null,g=a.clipAngle&&null!==(t=a.clipAngle())&&void 0!==t?t:0,m=g>0?g*Math.PI/180:null,b=a.rotate?a.rotate():[0,0,0],v="function"==typeof a.center?a.center():[0,0],x=[(null!==(n=v[0])&&void 0!==n?n:0)-b[0],(null!==(o=v[1])&&void 0!==o?o:0)-b[1]];for(let e=0;d.length>e;e++){const t=d[e],n=l(t),o=c(t);if(null!=m&&y([n,o],x)>m)continue;const s=a([n,o]);if(!s)continue;const u=i.pointStyle?i.pointStyle(t):Object.assign({},se),h={type:"point",x:s[0],y:s[1],r:u.r||4,style:u,datum:t,pointId:p?p(t)+"":void 0};r.push(h)}return r}applyCartogramTransform(e,t){var n,o,r;const i=this.scene.filter(e=>"point"===e.type);if(2>i.length)return;const a=null!==(n=e.strength)&&void 0!==n?n:1;if(0===a)return;const s=e.centerAccessor?"function"==typeof e.centerAccessor?e.centerAccessor:t=>t[e.centerAccessor]:e=>e.id,l="function"==typeof e.costAccessor?e.costAccessor:t=>t[e.costAccessor],c=i.find(t=>s(t.datum)+""==e.center+"");if(!c)return void("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${e.center}" not found in point data`));const u=c.x,d=c.y,p=i.map(e=>l(e.datum)).filter(e=>isFinite(e)&&e>=0),h=Math.max(...p,1),y=Math.min(t.width,t.height)/2,f=w().domain([0,h]).range([0,y]);this.cartogramLayout={cx:u,cy:d,maxCost:h,availableRadius:y},this.areas.length>0&&"production"!==process.env.NODE_ENV&&console.warn("GeoFrame: Distance cartogram does not support area rendering. Areas will be ignored. Remove areas or set projectionTransform to null to render them."),this.scene=this.scene.filter(e=>"geoarea"!==e.type||!e.interactive);for(const e of i){if(e===c)continue;const t=Math.atan2(e.y-d,e.x-u),n=Math.sqrt(Math.pow(e.x-u,2)+Math.pow(e.y-d,2)),o=l(e.datum),r=n+((isFinite(o)?f(o):n)-n)*a;e.x=u+Math.cos(t)*r,e.y=d+Math.sin(t)*r}const g=t.width/2,m=t.height/2,b=g-c.x,v=m-c.y;if(Math.abs(b)>.5||Math.abs(v)>.5)for(const e of i)e.x+=b,e.y+=v;this.cartogramLayout={cx:g,cy:m,maxCost:h,availableRadius:y};const x=this.scene.filter(e=>"line"===e.type);if(x.length>0&&"fractional"!==e.lineMode){const e=new Map;for(const t of i)t.pointId&&e.set(t.pointId,[t.x,t.y]);for(const t of x){const n=null===(o=t.datum)||void 0===o?void 0:o.source,i=null===(r=t.datum)||void 0===r?void 0:r.target;if(n&&i){const o=e.get(n+""),r=e.get(i+"");o&&r&&(t.path=[o,r])}}}}applyDecay(){var e,t,n;const o=this.config.decay;if(!o||!this.pointBuffer)return;const r=this.pointBuffer.size;if(0===r)return;const i=null!==(e=o.minOpacity)&&void 0!==e?e:.1,a=null!==(t=o.halfLife)&&void 0!==t?t:r/2,s=null!==(n=o.stepThreshold)&&void 0!==n?n:.5*r,l=this.scene.filter(e=>"point"===e.type);for(let e=0;l.length>e;e++){const t=r-1-e;let n;switch(o.type){case"exponential":n=i+Math.pow(.5,t/a)*(1-i);break;case"step":n=s>t?1:i;break;default:n=i+(r>1?1-t/(r-1):1)*(1-i)}l[e]._decayOpacity=n,l[e].style=Object.assign(Object.assign({},l[e].style),{opacity:n})}}applyPulse(){var e,t;const n=this.config.pulse;if(!n||!this.timestampBuffer)return;const o=null!==(e=n.duration)&&void 0!==e?e:500,r=performance.now(),i=this.scene.filter(e=>"point"===e.type),a=this.timestampBuffer.toArray();for(let e=0;i.length>e&&a.length>e;e++){const s=r-a[e];o>s&&(i[e]._pulseIntensity=1-s/o,i[e]._pulseColor=n.color||"rgba(255,255,255,0.6)",i[e]._pulseGlowRadius=null!==(t=n.glowRadius)&&void 0!==t?t:4)}}get hasActivePulses(){var e,t;if(!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const n=null!==(t=null===(e=this.config.pulse)||void 0===e?void 0:e.duration)&&void 0!==t?t:500,o=this.timestampBuffer.toArray()[this.timestampBuffer.size-1];return performance.now()-o<n}startTransition(e){var t,n;const o=null!==(n=null===(t=this.config.transition)||void 0===t?void 0:t.duration)&&void 0!==n?n:300;if(0>=o)return;const r=new Map;for(const t of e)"point"===t.type&&t.pointId&&r.set(t.pointId,[t.x,t.y]);const i=this.scene.filter(e=>"point"===e.type);let a=!1;for(const e of i)if(e.pointId){const t=r.get(e.pointId);t&&(e._targetX=e.x,e._targetY=e.y,e.x=t[0],e.y=t[1],(Math.abs(t[0]-e._targetX)>.5||Math.abs(t[1]-e._targetY)>.5)&&(a=!0))}a&&(this.activeTransition={startTime:performance.now(),duration:o})}advanceTransition(e){if(!this.activeTransition)return!1;const t=function(e,t){return Math.min((e-t.startTime)/t.duration,1)}(e,this.activeTransition),n=function(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}(t),o=this.scene.filter(e=>"point"===e.type);for(const e of o)if(null!=e._targetX&&null!=e._targetY){const t=e.y;e.x=te(e.x,e._targetX,n),e.y=te(t,e._targetY,n)}if(t>=1){for(const e of o)null!=e._targetX&&(e.x=e._targetX,e.y=e._targetY,e._targetX=void 0,e._targetY=void 0);return this.activeTransition=null,!1}return!0}}function ye(e,t=30){return Math.max((null!=e?e:4)+5,12,t)}function fe(e){return e instanceof Date?e:"number"==typeof e&&e>1e9?new Date(e):null}function ge(e,t){const n=fe(e);if(!n)return!1;const o=fe(t);return!o||n.getFullYear()!==o.getFullYear()||n.getMonth()!==o.getMonth()}function me(e,t,n,o,r,i){const a=e.filter(e=>"point"===e.type);let s=null,l=o;for(const e of a){const r=e.x-t,i=e.y-n,a=Math.sqrt(r*r+i*i);ye(e.r,o)>=a&&l>a&&(s=e,l=a)}if(s)return{node:s,distance:l};const c=e.filter(e=>"geoarea"===e.type&&!1!==e.interactive);for(let e=c.length-1;e>=0;e--){const o=c[e],[[i,a],[s,l]]=o.bounds;if(!(i>t||t>s||a>n||n>l)&&(o._cachedPath2D||(o._cachedPath2D=new Path2D(o.pathData)),r.isPointInPath(o._cachedPath2D,t,n)))return{node:o,distance:0}}const u=e.filter(e=>"line"===e.type);let d=null,p=o;for(const e of u){const{path:o}=e;for(let r=0;o.length-1>r;r++){const[i,a]=o[r],[s,l]=o[r+1],c=be(t,n,i,a,s,l);Math.max((e.style.strokeWidth||2)+4,5)>=c&&p>c&&(d=e,p=c)}}return d?{node:d,distance:p}:null}function be(e,t,n,o,r,i){const a=r-n,s=i-o,l=a*a+s*s;if(0===l)return Math.sqrt(Math.pow(e-n,2)+Math.pow(t-o,2));let c=((e-n)*a+(t-o)*s)/l;c=Math.max(0,Math.min(1,c));const u=o+c*s;return Math.sqrt(Math.pow(e-(n+c*a),2)+Math.pow(t-u,2))}const ve={fill:t=>e.createElement("rect",{style:t,width:16,height:16}),line:t=>e.createElement("line",{style:t,x1:0,y1:0,x2:16,y2:16})};function xe(e,t,n,o){let r;return r="function"==typeof n?n(e):(0,ve[n])(o(e,t)),r}function ke(){return e.createElement("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function we(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}function Ae({config:t,orientation:n="vertical",width:o=100}){const{colorFn:r,domain:i,label:a,format:s}=t,l=s||(e=>Math.round(100*e)/100+""),c="grad-legend-"+e.useId();if("horizontal"===n){const t=12,n=Math.min(o,200),s=Math.max(0,(o-n)/2),u=[];for(let t=0;64>=t;t++){const n=t/64;u.push(e.createElement("stop",{key:t,offset:100*n+"%",stopColor:r(i[0]+n*(i[1]-i[0]))}))}return e.createElement("g",{"aria-label":a||"Gradient legend"},e.createElement("defs",null,e.createElement("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"100%",y2:"0%"},u)),a&&e.createElement("text",{x:s+n/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},a),e.createElement("rect",{x:s,y:0,width:n,height:t,fill:`url(#${c})`,rx:2}),e.createElement("text",{x:s,y:t+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},l(i[0])),e.createElement("text",{x:s+n,y:t+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},l(i[1])))}const u=[];for(let t=0;64>=t;t++){const n=t/64;u.push(e.createElement("stop",{key:t,offset:100*n+"%",stopColor:r(i[1]-n*(i[1]-i[0]))}))}return e.createElement("g",{"aria-label":a||"Gradient legend"},a&&e.createElement("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},a),e.createElement("defs",null,e.createElement("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"0%",y2:"100%"},u)),e.createElement("rect",{x:0,y:0,width:14,height:100,fill:`url(#${c})`,rx:2}),e.createElement("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},l(i[1])),e.createElement("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},l(i[0])))}function je(t){const{legendGroups:n,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:a,legendInteraction:s,title:l="Legend",width:c=100,height:u=20,orientation:d="vertical"}=t,[p,h]=e.useState(0),[y,f]=e.useState(0),g=e.useCallback((e,t)=>{h(e),f(t)},[]),m="vertical"===d?(({legendGroups:t,width:n,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:a,focusedGroupIndex:s,focusedItemIndex:l,onFocusedIndexChange:c,legendInteraction:u})=>{let d=24;const p=[];return t.forEach((t,h)=>{d+=5,p.push(e.createElement("line",{key:"legend-top-line legend-symbol-"+h,stroke:"gray",x1:0,y1:d,x2:n,y2:d})),d+=8,t.label&&(d+=16,p.push(e.createElement("text",{key:"legend-text-"+h,y:d,className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},t.label)),d+=8),p.push(e.createElement("g",{key:"legend-group-"+h,className:"legend-item",transform:`translate(0,${d})`},((t,n,o,r,i,a,s,l,c,u)=>{const{type:d="fill",styleFn:p,items:h}=t,y=[];let f=0;const g=!(!n&&!o),m="isolate"===u||void 0===u&&null!=i;return h.forEach((t,u)=>{const b=xe(t,u,d,p),v=we(t,r,i),x=i&&i.size>0&&i.has(t.label);y.push(e.createElement("g",{key:"legend-item-"+u,transform:`translate(0,${f})`,onClick:n?()=>n(t):void 0,onMouseEnter:o?()=>o(t):void 0,onMouseLeave:o?()=>o(null):void 0,tabIndex:g?l===a&&u===s?0:-1:void 0,role:g?"option":void 0,"aria-selected":g&&m?x||!1:void 0,"aria-current":g&&!m&&null!=r&&t.label===r||void 0,"aria-label":t.label,onKeyDown:g?e=>{var o;if("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),n&&n(t)),"ArrowDown"===e.key||"ArrowUp"===e.key){e.preventDefault();const t=(u+("ArrowDown"===e.key?1:-1)+h.length)%h.length;c(l,t);const n=null===(o=e.currentTarget.parentElement)||void 0===o?void 0:o.children[t];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:g?e=>{c(l,u),o&&o(t);const n=e.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:g?e=>{o&&o(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:g?"pointer":"default",opacity:v,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},g&&e.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*t.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),b,x&&e.createElement(ke,null),e.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},t.label))),f+=22}),y})(t,o,r,i,a,s,l,h,c,u))),d+=22*t.items.length+8}),p})({legendGroups:n||[],width:c,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:a,focusedGroupIndex:p,focusedItemIndex:y,onFocusedIndexChange:g,legendInteraction:s}):(({legendGroups:t,height:n,width:o,customClickBehavior:r,customHoverBehavior:i,highlightedCategory:a,isolatedCategories:s,focusedGroupIndex:l,focusedItemIndex:c,onFocusedIndexChange:u,legendInteraction:d})=>{let p=0;const h=[];t.forEach((t,n)=>{let y=0;t.label&&(y+=16);const f=((t,n,o,r,i,a,s,l,c,u,d)=>{const{type:p="fill",styleFn:h,items:y}=t,f=[];let g=0,m=0;const b=!(!n&&!o),v="isolate"===u||void 0===u&&null!=i;y.forEach((t,u)=>{const x=xe(t,u,p,h),k=we(t,r,i),w=i&&i.size>0&&i.has(t.label),A=26+7*t.label.length;d&&d>0&&g>0&&g+A>d&&(m++,g=0),f.push(e.createElement("g",{key:"legend-item-"+u,transform:`translate(${g},${22*m})`,onClick:n?()=>n(t):void 0,onMouseEnter:o?()=>o(t):void 0,onMouseLeave:o?()=>o(null):void 0,tabIndex:b?l===a&&u===s?0:-1:void 0,role:b?"option":void 0,"aria-selected":b&&v?w||!1:void 0,"aria-current":b&&!v&&null!=r&&t.label===r||void 0,"aria-label":t.label,onKeyDown:b?e=>{var o;if("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),n&&n(t)),"ArrowRight"===e.key||"ArrowLeft"===e.key){e.preventDefault();const t=(u+("ArrowRight"===e.key?1:-1)+y.length)%y.length;c(l,t);const n=null===(o=e.currentTarget.parentElement)||void 0===o?void 0:o.children[t];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:b?e=>{c(l,u),o&&o(t);const n=e.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:b?e=>{o&&o(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:b?"pointer":"default",opacity:k,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},b&&e.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*t.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),x,w&&e.createElement(ke,null),e.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},t.label))),g+=A});let x=0,k=0;for(const e of y){const t=26+7*e.label.length;d&&d>0&&k>0&&k+t>d?(x=Math.max(x,k),k=t):k+=t}x=Math.max(x,k);const w=m+1;return{items:f,offset:x,totalRows:w,totalHeight:22*w}})(t,r,i,a,s,l,c,n,u,d,o);y+=f.offset+5,h.push(Object.assign(Object.assign({label:t.label},f),{offset:y,totalRows:f.totalRows,totalHeight:f.totalHeight})),p+=y+12});let y=p>o?0:Math.max(0,(o-p)/2);const f=[];return h.forEach((o,r)=>{const i=t[r];i.label&&(f.push(e.createElement("text",{key:"legend-text-"+r,transform:`translate(${y},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},i.label)),y+=16),f.push(e.createElement("g",{key:"legend-group-"+r,className:"legend-item",transform:`translate(${y},0)`},o.items)),y+=o.offset+5,t[r+1]&&f.push(e.createElement("line",{key:"legend-top-line legend-symbol-"+r,stroke:"gray",x1:y,y1:-8,x2:y,y2:(o.totalHeight||n)+0+8})),y+=12}),e.createElement("g",null,f)})({legendGroups:n||[],title:l,height:u,width:c,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:a,focusedGroupIndex:p,focusedItemIndex:y,onFocusedIndexChange:g,legendInteraction:s}),b=!(!o&&!r);return e.createElement("g",{role:b?"listbox":void 0,"aria-multiselectable":!(!b||"isolate"!==s&&(void 0!==s||null==a))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"}},void 0!==l&&""!==l&&"vertical"===d&&e.createElement("text",{className:"legend-title",y:16,x:c/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)"},l),m)}function Ee(e){return"string"==typeof e?{type:e}:e}function Oe({orient:t,config:n,values:o,scale:i,size:a,length:s}){const l=function(e){var t,n,o,r,i;return{type:e.type,bins:null!==(t=e.bins)&&void 0!==t?t:20,fill:null!==(n=e.fill)&&void 0!==n?n:"#4e79a7",fillOpacity:null!==(o=e.fillOpacity)&&void 0!==o?o:.5,stroke:null!==(r=e.stroke)&&void 0!==r?r:"none",strokeWidth:null!==(i=e.strokeWidth)&&void 0!==i?i:1}}(n),c="top"===t||"bottom"===t,u=r(()=>{if(0===o.length)return null;const n=i.domain(),r=a-8;if("boxplot"===l.type){const n=function(e){const t=[...e].sort((e,t)=>e-t),n=t.length;if(0===n)return null;const o=t[Math.floor(.25*n)],r=t[Math.floor(.5*n)],i=t[Math.floor(.75*n)],a=i-o;return{q1:o,median:r,q3:i,whiskerLow:Math.max(t[0],o-1.5*a),whiskerHigh:Math.min(t[n-1],i+1.5*a)}}(o);if(!n)return null;const{q1:a,median:s,q3:u,whiskerLow:d,whiskerHigh:p}=n,h=Math.min(.5*r,20),y=(r-h)/2+4;if(c){const n=i(a),o=i(u),r=i(s),c=i(d),f=i(p),g="top"===t?-1:1,m=0;return e.createElement("g",{"data-testid":"marginal-boxplot-"+t},e.createElement("line",{x1:c,y1:m+g*(y+h/2),x2:f,y2:m+g*(y+h/2),stroke:l.fill,strokeWidth:l.strokeWidth}),e.createElement("line",{x1:c,y1:m+g*y,x2:c,y2:m+g*(y+h),stroke:l.fill,strokeWidth:l.strokeWidth}),e.createElement("line",{x1:f,y1:m+g*y,x2:f,y2:m+g*(y+h),stroke:l.fill,strokeWidth:l.strokeWidth}),e.createElement("rect",{x:Math.min(n,o),y:"top"===t?m-y-h:m+y,width:Math.abs(o-n),height:h,fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}),e.createElement("line",{x1:r,y1:"top"===t?m-y-h:m+y,x2:r,y2:"top"===t?m-y:m+y+h,stroke:l.fill,strokeWidth:2}))}{const n=i(a),o=i(u),r=i(s),c=i(d),f=i(p),g="left"===t?-1:1,m=0;return e.createElement("g",{"data-testid":"marginal-boxplot-"+t},e.createElement("line",{x1:m+g*(y+h/2),y1:c,x2:m+g*(y+h/2),y2:f,stroke:l.fill,strokeWidth:l.strokeWidth}),e.createElement("line",{x1:m+g*y,y1:c,x2:m+g*(y+h),y2:c,stroke:l.fill,strokeWidth:l.strokeWidth}),e.createElement("line",{x1:m+g*y,y1:f,x2:m+g*(y+h),y2:f,stroke:l.fill,strokeWidth:l.strokeWidth}),e.createElement("rect",{x:"left"===t?m-y-h:m+y,y:Math.min(n,o),width:h,height:Math.abs(o-n),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}),e.createElement("line",{x1:"left"===t?m-y-h:m+y,y1:r,x2:"left"===t?m-y:m+y+h,y2:r,stroke:l.fill,strokeWidth:2}))}}const u=E().domain(n).thresholds(l.bins)(o);if(0===u.length)return null;const d=Math.max(...u.map(e=>e.length));if(0===d)return null;if("histogram"===l.type)return e.createElement("g",{"data-testid":"marginal-histogram-"+t},u.map((n,o)=>{if(null==n.x0||null==n.x1)return null;const a=n.length/d*r;if(c){const r=i(n.x0),s=i(n.x1)-i(n.x0);return e.createElement("rect",{key:o,x:r,y:"top"===t?-4-a:4,width:Math.max(s,.5),height:a,fill:l.fill,fillOpacity:l.fillOpacity,stroke:l.stroke,strokeWidth:l.strokeWidth})}{const r=i(n.x0),s=i(n.x1)-i(n.x0);return e.createElement("rect",{key:o,x:"left"===t?-4-a:4,y:Math.min(r,r+s),width:a,height:Math.abs(s),fill:l.fill,fillOpacity:l.fillOpacity,stroke:l.stroke,strokeWidth:l.strokeWidth})}}));if("violin"===l.type){const n=r/2+4,o=[];for(const e of u){if(null==e.x0||null==e.x1)continue;const a=e.length/d*(r/2),s=i((e.x0+e.x1)/2);o.push(c?`${s},${"top"===t?-(n-a):n-a}`:`${"left"===t?-(n-a):n-a},${s}`)}for(let e=u.length-1;e>=0;e--){const a=u[e];if(null==a.x0||null==a.x1)continue;const s=a.length/d*(r/2),l=i((a.x0+a.x1)/2);o.push(c?`${l},${"top"===t?-(n+s):n+s}`:`${"left"===t?-(n+s):n+s},${l}`)}return e.createElement("g",{"data-testid":"marginal-violin-"+t},e.createElement("polygon",{points:o.join(" "),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}))}if("ridgeline"===l.type){const n=[];if(c){const e=0,o=null!=u[0].x0?i(u[0].x0):0;n.push(`M${o},${e}`);for(const e of u){if(null==e.x0||null==e.x1)continue;const o=e.length/d*r,a=i((e.x0+e.x1)/2);n.push(`L${a},${"top"===t?-o-4:o+4}`)}const a=null!=u[u.length-1].x1?i(u[u.length-1].x1):s;n.push(`L${a},${e}`),n.push("Z")}else{const e=0,o=null!=u[0].x0?i(u[0].x0):0;n.push(`M${e},${o}`);for(const e of u){if(null==e.x0||null==e.x1)continue;const o=e.length/d*r,a=i((e.x0+e.x1)/2);n.push(`L${"left"===t?-o-4:o+4},${a}`)}const a=null!=u[u.length-1].x1?i(u[u.length-1].x1):s;n.push(`L${e},${a}`),n.push("Z")}return e.createElement("g",{"data-testid":"marginal-ridgeline-"+t},e.createElement("path",{d:n.join(" "),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}))}return null},[o,i,l,a,s,t,c,4]);return u?e.createElement("g",{className:"marginal-"+t,"data-testid":"marginal-"+t},u):null}function Se(e,t=120,n=8){if(!e)return[];const o=Math.max(1,Math.floor(t/n)),r=e.split(/\s+/),i=[];let a="";for(const e of r)a&&a.length+1+e.length>o?(i.push(a),a=e):a=a?`${a} ${e}`:e;return a&&i.push(a),i}function Me(e,t,n,o){return"curly"===e?o?`M0,0 C${.6*n},0 ${.4*n},${t/2} ${n},${t/2} C${.4*n},${t/2} ${.6*n},${t} 0,${t}`:`M0,0 C0,${.6*n} ${t/2},${.4*n} ${t/2},${n} C${t/2},${.4*n} ${t},${.6*n} ${t},0`:o?`M0,0 L${n},0 L${n},${t} L0,${t}`:`M0,0 L0,${n} L${t},${n} L${t},0`}function Ce(t){const{x:n=0,y:o=0,dx:r,dy:i,nx:a,ny:s,note:l,connector:c,subject:u,type:d,color:p,className:h,disable:y,events:f={},"data-testid":g}=t,m=new Set(Array.isArray(y)?y:[]);let b=r||0,v=i||0;null!=a&&(b=a-n),null!=s&&(v=s-o);const x="string"==typeof d?d:"label";if("bracket"===x&&u&&0===b&&0===v)if(void 0!==u.width){b=u.width/2;const e=u.depth||30;v=e+(0>e?-5:5)}else if(void 0!==u.height){const e=u.depth||30;b=e+(0>e?-5:5),v=u.height/2}return e.createElement("g",Object.assign({className:("annotation "+(h||"")).trim(),transform:`translate(${n},${o})`,"data-testid":g},f),!m.has("connector")&&function(t,n,o,r,i,a){const s=[];let l=0,c=0;if("callout-circle"!==i&&"label"!==i||!(null==a?void 0:a.radius)){if("callout-rect"===i&&a){const e=a.width||0,o=a.height||0;if(e>0||o>0){const r=e/2,i=o/2,a=t-r,s=n-i;if(0!==a||0!==s){const t=Math.abs(a),n=Math.abs(s),u=e/2,d=o/2,p=t*d>n*u?u/t:d/n;l=r+a*p,c=i+s*p}}}else if("bracket"===i&&a){const e=a.width,t=a.height,n=a.depth||30;void 0!==e?(l=e/2,c=n):void 0!==t&&(l=n,c=t/2)}}else{const e=(a.radius||0)+(a.radiusPadding||0);if(e>0&&(0!==t||0!==n)){const o=Math.atan2(n,t);l=Math.cos(o)*e,c=Math.sin(o)*e}}if(Math.sqrt(Math.pow(t-l,2)+Math.pow(n-c,2))>.5&&(s.push(e.createElement("line",{key:"connector-line",x1:l,y1:c,x2:t,y2:n,stroke:r||"var(--semiotic-text-secondary, currentColor)"})),"arrow"===(null==o?void 0:o.end))){const o=10,i=16/180*Math.PI,a=Math.atan2(n-c,t-l);s.push(e.createElement("path",{key:"connector-arrow",d:`M${l},${c}L${l+o*Math.cos(a+i)},${c+o*Math.sin(a+i)}L${l+o*Math.cos(a-i)},${c+o*Math.sin(a-i)}Z`,fill:r||"var(--semiotic-text-secondary, currentColor)",stroke:"none"}))}return e.createElement("g",{className:"annotation-connector"},s)}(b,v,c,p,x,u),!m.has("subject")&&function(t,n,o,r,i){var a;const s=[];switch(t){case"callout-circle":{const t=((null==n?void 0:n.radius)||0)+((null==n?void 0:n.radiusPadding)||0);t>0&&s.push(e.createElement("circle",{key:"subject-circle",r:t,fill:"none",stroke:o||"var(--semiotic-text-secondary, currentColor)"}));break}case"callout-rect":{const t=(null==n?void 0:n.width)||0,r=(null==n?void 0:n.height)||0;(t>0||r>0)&&s.push(e.createElement("rect",{key:"subject-rect",width:t,height:r,fill:"none",stroke:o||"var(--semiotic-text-secondary, currentColor)"}));break}case"callout-custom":(null==n?void 0:n.custom)&&s.push(...Array.isArray(n.custom)?n.custom:[n.custom]);break;case"xy-threshold":{const t=r||0,a=i||0;if(void 0!==(null==n?void 0:n.x)){const r=(n.x||0)-t;s.push(e.createElement("line",{key:"threshold-line",x1:r,y1:(n.y1||0)-a,x2:r,y2:(n.y2||0)-a,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"}))}else if(void 0!==(null==n?void 0:n.y)){const r=(n.y||0)-a;s.push(e.createElement("line",{key:"threshold-line",x1:(n.x1||0)-t,y1:r,x2:(n.x2||0)-t,y2:r,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"}))}else void 0!==(null==n?void 0:n.x1)||void 0!==(null==n?void 0:n.x2)?s.push(e.createElement("line",{key:"threshold-line",x1:(n.x1||0)-t,y1:0,x2:(n.x2||0)-t,y2:0,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"})):void 0===(null==n?void 0:n.y1)&&void 0===(null==n?void 0:n.y2)||s.push(e.createElement("line",{key:"threshold-line",x1:0,y1:(n.y1||0)-a,x2:0,y2:(n.y2||0)-a,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"}));break}case"bracket":{const t=null!==(a=null==n?void 0:n.width)&&void 0!==a?a:null==n?void 0:n.height;void 0!==t&&s.push(e.createElement("path",{key:"bracket-path",d:Me((null==n?void 0:n.type)||"curly",t,(null==n?void 0:n.depth)||30,void 0===(null==n?void 0:n.width)),fill:"none",stroke:o||"var(--semiotic-text-secondary, currentColor)"}));break}}return e.createElement("g",{className:"annotation-subject"},s)}(x,u,p,n,o),!m.has("note")&&function(t,n,o,r){if(!t)return e.createElement("g",{className:"annotation-note"});const{label:i,title:a,orientation:s,align:l,wrap:c=120,noWrap:u}=t;if(!i&&!a)return e.createElement("g",{className:"annotation-note"});let d=s;d||(d=Math.abs(n)>Math.abs(o)?"leftRight":"topBottom");let p=l;p&&"dynamic"!==p||(p="topBottom"===d?0>n?"right":"left":0>o?"bottom":"top");let h="start";"topBottom"===d?"right"===p?h="end":"middle"===p&&(h="middle"):h=0>n?"end":"start";const y=16,f=a?u?[a]:Se(a,c):[],g=i?u?[i]:Se(i,c):[],m="leftRight"===d?"end"===h?-4:4:0;let b=0;const v=[],x=r||"var(--semiotic-text, #333)";f.length>0&&(v.push(e.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:x,textAnchor:h,fontWeight:"bold"},f.map((t,n)=>e.createElement("tspan",{key:n,x:m,dy:0===n?0:y},t)))),b=f.length*y),g.length>0&&v.push(e.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:x,textAnchor:h,y:b},g.map((t,n)=>e.createElement("tspan",{key:n,x:m,dy:0===n?0:y},t))));let k=null;if((a||i)&&(0!==n||0!==o))if("topBottom"===d){const t=Math.min(c,120);let n=0,o=t;"end"===h?(n=-t,o=0):"middle"===h&&(n=-t/2,o=t/2),k=e.createElement("line",{className:"note-line",x1:n,x2:o,y1:0,y2:0,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}else{const t=(f.length+g.length)*y+(g.length>0?y:0);let n=0,o=t;"bottom"===p?(n=-t,o=0):"middle"===p&&(n=-t/2,o=t/2),k=e.createElement("line",{className:"note-line",x1:0,x2:0,y1:n,y2:o,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}const w=Math.max(0,f.length+g.length-1)*y;let A=0;return"topBottom"===d?A=0>o?-(w+2):18:"leftRight"===d&&(A="middle"===p?-(w+y+(g.length>0&&f.length>0?2:0))/2+8:"bottom"===p||0>o?-(w+2):18),e.createElement("g",{className:"annotation-note",transform:`translate(${n},${o})`},e.createElement("g",{className:"annotation-note-content",transform:0!==A?`translate(0,${A})`:void 0},v),k)}(l,b,v,p))}function $e(t){var n,o;const{noteData:r}=t,{screenCoordinates:i}=r,a="string"==typeof r.type?r.type:"label",s=r.eventListeners||r.events||{};if(r.coordinates&&i){const t=r.nx||i[0][0]+(null!==(n=r.dx)&&void 0!==n?n:0),s=r.ny||i[0][1]+(null!==(o=r.dy)&&void 0!==o?o:0),l=i.map((n,o)=>{const i=Object.assign({},r,{note:0===o?r.note:{label:""},x:n[0],y:n[1],nx:t,ny:s});return e.createElement(Ce,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+o},i,{type:a}))});return e.createElement("g",null,l)}const l=r.note||{title:"none",label:r.label};return e.createElement(Ce,Object.assign({"data-testid":"semiotic-annotation",key:`${l.label}-${l.title}-${r.i}`,events:s},r,{type:a}))}function ze(e,t){var n,o,r;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.x)&&void 0!==o?o:null===(r=t.scales)||void 0===r?void 0:r.time;return i?null!=e.x?i(e.x):t.xAccessor&&null!=e[t.xAccessor]?i(e[t.xAccessor]):null:null}function Le(e,t){var n,o,r;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.y)&&void 0!==o?o:null===(r=t.scales)||void 0===r?void 0:r.value;return i?null!=e.y?i(e.y):t.yAccessor&&null!=e[t.yAccessor]?i(e[t.yAccessor]):null:null}function Pe(e,t,n){var o,r,i,a;const s=e.anchor||"fixed";if("latest"===s){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let r=n.pointNodes.length-1;r>=0;r--){const i=n.pointNodes[r];if(i.pointId===e.pointId){const e={x:i.x,y:i.y};return null===(o=n.stickyPositionCache)||void 0===o||o.set(t,e),e}}const i=function(e){var t,n,o,r,i,a;const s=e.data;if(!s||0===s.length)return null;const l=s[s.length-1],c=null!==(n=null===(t=e.scales)||void 0===t?void 0:t.x)&&void 0!==n?n:null===(o=e.scales)||void 0===o?void 0:o.time,u=null!==(i=null===(r=e.scales)||void 0===r?void 0:r.y)&&void 0!==i?i:null===(a=e.scales)||void 0===a?void 0:a.value;if(!c||!u)return null;const d=l[e.xAccessor||"x"],p=l[e.yAccessor||"y"];return null==d||null==p?null:{x:c(d),y:u(p)}}(n);return i&&(null===(r=n.stickyPositionCache)||void 0===r||r.set(t,i)),i}let l=null,c=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(l=t.x,c=t.y)}if(null!=l&&null!=c||(l=ze(e,n),c=Le(e,n)),null!=l&&null!=c)return null===(i=n.stickyPositionCache)||void 0===i||i.set(t,{x:l,y:c}),{x:l,y:c};if("sticky"===s){const e=null===(a=n.stickyPositionCache)||void 0===a?void 0:a.get(t);if(e)return e}return null}function Be(e,t,n,o=50){return!(-o>e||e>(n.width||0)+o||-o>t||t>(n.height||0)+o)}const Ie={linear:D,monotoneX:N,monotoneY:I,step:B,stepAfter:P,stepBefore:L,basis:z,cardinal:$,catmullRom:C};let Ne={positions:new Map};const De=new Set;function Te(){for(const e of De)e()}function Re(e,t){const n=Ne.positions.get(e);if(null==n?void 0:n.locked)return;if(!n||n.sourceId!==t)return;const o=new Map(Ne.positions);o.delete(e),Ne={positions:o},Te()}function We(e,t){const n=Ne.positions.get(e);if(!(null==n?void 0:n.locked))return;if(t&&n.sourceId!==t)return;const o=new Map(Ne.positions);o.delete(e),Ne={positions:o},Te()}function _e(){return Ne}function Fe(e){return De.add(e),()=>De.delete(e)}const He={positions:new Map};function qe(){return()=>{}}function Ge(){return He}function Ve(e){if(e)return"dashed"===e?"6,4":"dotted"===e?"2,4":e}function Ue(e,t,n){if("left"===e||"right"===e){const o="left"===e?n:0,r="left"===e?-1:1,i=Math.ceil(t/8);let a="M0,"+o;for(let e=0;i>e;e++){const n=8*(e+1);a+=`L${Math.min(8*e+4,t)},${o+4*r}`,a+=`L${Math.min(n,t)},${o}`}return a}{const o="bottom"===e?0:t,r="bottom"===e?1:-1,i=Math.ceil(n/8);let a=`M${o},0`;for(let e=0;i>e;e++){const t=8*(e+1);a+=`L${o+4*r},${Math.min(8*e+4,n)}`,a+=`L${o},${Math.min(t,n)}`}return a}}function Ze(e,t,n){return e instanceof Date?`${e.toLocaleString("en",{month:"short"})} ${e.getDate()}`:"number"==typeof e?Math.round(100*e)/100+"":e+""}function Ye(e,t){if(2>=e.length)return e;const n=[e[0]];for(let o=1;e.length-1>o;o++)t>Math.abs(e[o].pixel-n[n.length-1].pixel)||n.push(e[o]);const o=e[e.length-1];return t>Math.abs(o.pixel-n[n.length-1].pixel)?n[n.length-1]=o:n.push(o),n}function Xe(n){var a,s;const{width:l,height:c,totalWidth:u,totalHeight:d,margin:p,scales:h,showAxes:y,axes:f,xLabel:g,yLabel:m,yLabelRight:b,xFormat:v,yFormat:x,showGrid:k,title:w,legend:A,legendHoverBehavior:j,legendClickBehavior:E,legendHighlightedCategory:O,legendIsolatedCategories:C,legendPosition:$="right",foregroundGraphics:z,marginalGraphics:L,xValues:P,yValues:B,annotations:I,svgAnnotationRules:N,xAccessor:T,yAccessor:R,annotationData:_,pointNodes:F,curve:H,underlayRendered:q,linkedCrosshairName:G,linkedCrosshairSourceId:V,children:U}=n,Z=r(()=>{var e;if(!y||!h)return[];const t=null==f?void 0:f.find(e=>"bottom"===e.orient),n=(null==t?void 0:t.tickFormat)||v||Ze,o=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5,r=h.x.ticks(Math.min(o,Math.max(2,Math.floor(l/70)))),i=r.map(e=>e.valueOf()),a=r.map((e,t)=>({value:e,pixel:h.x(e),label:n(e,t,i)})),s=a.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0),c=(null==t?void 0:t.autoRotate)?Math.max(20,Math.min(s+8,55)):Math.max(55,s+8);let u=Ye(a,c);if(u.length>1&&(u=u.filter((e,t)=>0===t||e.label+""!=u[t-1].label+"")),(null==t?void 0:t.includeMax)&&u.length>0){const e=h.x.domain()[1],t=h.x(e),o=u[u.length-1].pixel;if(Math.abs(t-o)>1){const r=n(e,u.length,i);c>t-o&&u.length>1&&(u=u.slice(0,-1)),u.push({value:e,pixel:t,label:r})}}return u},[y,h,f,v,l]),Y=r(()=>{var e;if(!y||!h)return[];const t=null==f?void 0:f.find(e=>"left"===e.orient),n=(null==t?void 0:t.tickFormat)||x||Ze,o=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;let r=Ye(h.y.ticks(Math.min(o,Math.max(2,Math.floor(c/30)))).map(e=>({value:e,pixel:h.y(e),label:n(e)})),22);if(r.length>1&&(r=r.filter((e,t)=>0===t||e.label+""!=r[t-1].label+"")),(null==t?void 0:t.includeMax)&&r.length>0){const e=h.y.domain()[1],t=h.y(e),o=r[r.length-1].pixel;if(Math.abs(t-o)>1){const i=n(e);22>Math.abs(t-o)&&r.length>1&&(r=r.slice(0,-1)),r.push({value:e,pixel:t,label:i})}}return r},[y,h,f,x,c]),X=r(()=>{var e;if(!y||!h)return[];const t=null==f?void 0:f.find(e=>"right"===e.orient);if(!t)return[];const n=t.tickFormat||x||Ze,o=null!==(e=t.ticks)&&void 0!==e?e:5;return Ye(h.y.ticks(Math.min(o,Math.max(2,Math.floor(c/30)))).map(e=>({value:e,pixel:h.y(e),label:n(e)})),22)},[y,h,f,x,c]),K=t(new Map),J=t(null!==(a=null==I?void 0:I.length)&&void 0!==a?a:0),Q=null!==(s=null==I?void 0:I.length)&&void 0!==s?s:0;J.current!==Q&&(J.current=Q,K.current=new Map);const ee=r(()=>{if(!I||0===I.length)return null;const t=function(t,n,o){var r,i,a,s,l,c,u,d,p,h,y,f,g,m,b,v,x,k,w,A,j,E,O,C,$,z,L,P,B,I,N,T,R,_,F,H,q,G,V,U,Z,Y,X,K,J,Q,ee,te;switch(t.type){case"label":{const r=Pe(t,n,o);if(!r)return null;const{x:i,y:a}=r;return Be(i,a,o)?e.createElement($e,{key:"ann-"+n,noteData:{x:i,y:a,dx:t.dx||30,dy:t.dy||-30,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"label",connector:t.connector||{end:"arrow"},color:t.color}}):null}case"callout":{const r=Pe(t,n,o);if(!r)return null;const{x:i,y:a}=r;return Be(i,a,o)?e.createElement($e,{key:"ann-"+n,noteData:{x:i,y:a,dx:t.dx||30,dy:t.dy||-30,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"callout-circle",subject:{radius:t.radius||12},connector:t.connector||{end:"arrow"},color:t.color}}):null}case"x-threshold":{const r=ze(t,o);if(null==r)return null;const i=t.color||"#f97316",a=t.labelPosition||"top";let s;return s="bottom"===a?(o.height||0)-4:"center"===a?(o.height||0)/2:12,e.createElement("g",{key:"ann-"+n},e.createElement("line",{x1:r,y1:0,x2:r,y2:o.height||0,stroke:i,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.createElement("text",{x:r+4,y:s,fill:i,fontSize:12,fontWeight:"bold"},t.label))}case"y-threshold":{const r=Le(t,o);if(null==r)return null;const i=t.color||"#f97316",a=t.labelPosition||"right";let s,l;return"left"===a?(s=4,l="start"):"center"===a?(s=(o.width||0)/2,l="middle"):(s=(o.width||0)-4,l="end"),e.createElement("g",{key:"ann-"+n},e.createElement("line",{x1:0,y1:r,x2:o.width||0,y2:r,stroke:i,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.createElement("text",{x:s,y:r-4,textAnchor:l,fill:i,fontSize:12,fontWeight:"bold"},t.label))}case"enclose":{const r=(t.coordinates||[]).map(e=>({x:ze(Object.assign(Object.assign({},e),{type:"point"}),o),y:Le(Object.assign(Object.assign({},e),{type:"point"}),o),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>r.length)return null;const i=S(r),a=t.padding||10;return e.createElement("g",{key:"ann-"+n},e.createElement("circle",{cx:i.x,cy:i.y,r:i.r+a,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&e.createElement("text",{x:i.x,y:i.y-i.r-a-4,textAnchor:"middle",fill:t.color||"var(--semiotic-text-secondary, #666)",fontSize:12},t.label))}case"rect-enclose":{const r=(t.coordinates||[]).map(e=>({x:ze(Object.assign(Object.assign({},e),{type:"point"}),o),y:Le(Object.assign(Object.assign({},e),{type:"point"}),o)})).filter(e=>null!=e.x&&null!=e.y);if(2>r.length)return null;const i=t.padding||10,a=r.map(e=>e.x),s=r.map(e=>e.y),l=Math.min(...a)-i,c=Math.max(...a)+i,u=Math.min(...s)-i,d=Math.max(...s)+i;return e.createElement("g",{key:"ann-"+n},e.createElement("rect",{x:l,y:u,width:c-l,height:d-u,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&e.createElement("text",{x:(l+c)/2,y:u-4,textAnchor:"middle",fill:t.color||"var(--semiotic-text-secondary, #666)",fontSize:12},t.label))}case"highlight":{const r=o.data||[],i="function"==typeof t.filter?r.filter(t.filter):t.field&&null!=t.value?r.filter(e=>e[t.field]===t.value):[],a={stroke:t.color||"#f97316",strokeWidth:2,fill:"none"};return e.createElement("g",{key:"ann-"+n},i.map((n,r)=>{const i=ze(n,o),s=Le(n,o);if(null==i||null==s)return null;const l="function"==typeof t.r?t.r(n):t.r||6,c="function"==typeof t.style?t.style(n):t.style||a;return e.createElement("circle",Object.assign({key:"hl-"+r,cx:i,cy:s,r:l},c))}))}case"bracket":{const r=ze(t,o),i=Le(t,o);return e.createElement($e,{key:"ann-"+n,noteData:{x:null!=r?r:0,y:null!=i?i:0,dx:t.dx||0,dy:t.dy||0,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"bracket",subject:{type:t.bracketType||"curly",width:t.width,height:t.height,depth:t.depth||30},color:t.color}})}case"trend":{const d=o.data||[];if(2>d.length)return null;const p=o.xAccessor||"x",h=o.yAccessor||"y",y=d.map(e=>[e[p],e[h]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>y.length)return null;const f=null!==(i=null===(r=o.scales)||void 0===r?void 0:r.x)&&void 0!==i?i:null===(a=o.scales)||void 0===a?void 0:a.time,g=null!==(l=null===(s=o.scales)||void 0===s?void 0:s.y)&&void 0!==l?l:null===(c=o.scales)||void 0===c?void 0:c.value;if(!f||!g)return null;const m=t.method||"linear";let b;b="loess"===m?function(e,t=.3){const n=e.length;if(2>n)return e.slice();const o=e.slice().sort((e,t)=>e[0]-t[0]),r=o.map(e=>e[0]),i=o.map(e=>e[1]),a=Math.max(2,Math.ceil(t*n)),s=[];for(let e=0;n>e;e++){const t=r[e],o=r.map(e=>Math.abs(e-t)),l=o.slice().sort((e,t)=>e-t)[Math.min(a-1,n-1)]||1,c=[];for(let e=0;n>e;e++){const t=0===l?0:o[e]/l;c[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,d=0,p=0,h=0,y=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(u+=t,d+=t*r[e],p+=t*i[e],h+=t*r[e]*r[e],y+=t*r[e]*i[e])}if(0===u){s.push([t,i[e]]);continue}const f=u*h-d*d;if(1e-12>Math.abs(f))s.push([t,p/u]);else{const e=(u*y-d*p)/f;s.push([t,(p-e*d)/u+e*t])}}return s}(y,null!==(u=t.bandwidth)&&void 0!==u?u:.3):("polynomial"===m?W.polynomial(y,{order:t.order||2}):W.linear(y)).points;const v=b.map(([e,t])=>`${f(e)},${g(t)}`).join(" "),x=t.color||"#6366f1";return e.createElement("g",{key:"ann-"+n},e.createElement("polyline",{points:v,fill:"none",stroke:x,strokeWidth:t.strokeWidth||2,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.createElement("text",{x:f(b[b.length-1][0])+4,y:g(b[b.length-1][1])-4,fill:x,fontSize:11},t.label))}case"band":{const r=null!==(p=null===(d=o.scales)||void 0===d?void 0:d.y)&&void 0!==p?p:null===(h=o.scales)||void 0===h?void 0:h.value,i=null!==(y=null==r?void 0:r(t.y0))&&void 0!==y?y:0,a=null!==(f=null==r?void 0:r(t.y1))&&void 0!==f?f:o.height||0;return e.createElement("g",{key:"ann-"+n},e.createElement("rect",{x:0,y:Math.min(i,a),width:o.width||0,height:Math.abs(a-i),fill:t.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:t.fillOpacity||.1}),t.label&&e.createElement("text",{x:(o.width||0)-4,y:Math.min(i,a)-4,textAnchor:"end",fill:t.color||"var(--semiotic-primary, #6366f1)",fontSize:11},t.label))}case"envelope":{const r=o.data||[];if(2>r.length)return null;const i=o.xAccessor||"x",a=null!==(m=null===(g=o.scales)||void 0===g?void 0:g.x)&&void 0!==m?m:null===(b=o.scales)||void 0===b?void 0:b.time,s=null!==(x=null===(v=o.scales)||void 0===v?void 0:v.y)&&void 0!==x?x:null===(k=o.scales)||void 0===k?void 0:k.value;if(!a||!s)return null;const l=t.upperAccessor||"upperBounds",c=t.lowerAccessor||"lowerBounds",u=t.filter,d=r.filter(e=>null!=e[l]&&null!=e[c]&&!(u&&!u(e))).sort((e,t)=>e[i]-t[i]);if(2>d.length)return null;const p=Ie[o.curve||"linear"]||D,h=M().x(e=>a(e[i])).y0(e=>s(e[c])).y1(e=>s(e[l])).curve(p)(d);if(!h)return null;const y=t.fill||"#6366f1";return e.createElement("g",{key:"ann-"+n},e.createElement("path",{d:h,fill:y,fillOpacity:null!==(w=t.fillOpacity)&&void 0!==w?w:.15,stroke:"none"}),t.label&&d.length>0&&e.createElement("text",{x:a(d[d.length-1][i])+4,y:s(d[d.length-1][l])-4,fill:y,fontSize:11},t.label))}case"anomaly-band":{const r=o.data||[];if(2>r.length)return null;const i=o.yAccessor||"y",a=null!==(j=null===(A=o.scales)||void 0===A?void 0:A.x)&&void 0!==j?j:null===(E=o.scales)||void 0===E?void 0:E.time,s=null!==(C=null===(O=o.scales)||void 0===O?void 0:O.y)&&void 0!==C?C:null===($=o.scales)||void 0===$?void 0:$.value;if(!a||!s)return null;const l=r.map(e=>e[i]).filter(e=>null!=e&&isFinite(e));if(2>l.length)return null;const c=l.reduce((e,t)=>e+t,0)/l.length,u=l.reduce((e,t)=>e+Math.pow(t-c,2),0)/l.length,d=Math.sqrt(u),p=null!==(z=t.threshold)&&void 0!==z?z:2,h=c-p*d,y=!1!==t.showBand,f=t.fill||"#6366f1",g=null!==(L=t.fillOpacity)&&void 0!==L?L:.1,m=t.anomalyColor||"#ef4444",b=null!==(P=t.anomalyRadius)&&void 0!==P?P:6,v=s(c+p*d),x=s(h),k=r.filter(e=>{const t=e[i];return null!=t&&Math.abs(t-c)>p*d});return e.createElement("g",{key:"ann-"+n},y&&e.createElement("rect",{x:0,y:Math.min(v,x),width:o.width||0,height:Math.abs(x-v),fill:f,fillOpacity:g}),k.map((t,n)=>{const r=ze(t,o),i=Le(t,o);return null==r||null==i?null:e.createElement("circle",{key:"anomaly-"+n,cx:r,cy:i,r:b,fill:m,fillOpacity:.7,stroke:m,strokeWidth:1.5})}),t.label&&e.createElement("text",{x:(o.width||0)-4,y:Math.min(v,x)-4,textAnchor:"end",fill:f,fontSize:11},t.label))}case"forecast":{const r=o.data||[];if(3>r.length)return null;const i=o.xAccessor||"x",a=o.yAccessor||"y",s=null!==(I=null===(B=o.scales)||void 0===B?void 0:B.x)&&void 0!==I?I:null===(N=o.scales)||void 0===N?void 0:N.time,l=null!==(R=null===(T=o.scales)||void 0===T?void 0:T.y)&&void 0!==R?R:null===(_=o.scales)||void 0===_?void 0:_.value;if(!s||!l)return null;const c=r.map(e=>[e[i],e[a]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>c.length)return null;let u;if("polynomial"===(t.method||"linear")){const e=W.polynomial(c,{order:t.order||2}).equation;u=t=>e.reduce((e,n,o)=>e+n*Math.pow(t,o),0)}else{const e=c.length;let t=0,n=0,o=0,r=0;for(const[e,i]of c)t+=e,n+=i,o+=e*e,r+=e*i;const i=e*o-t*t;if(1e-12>Math.abs(i))return null;const a=(e*r-t*n)/i,s=(n-a*t)/e;u=e=>s+a*e}const d=c.length,p=c.map(([e,t])=>t-u(e)).reduce((e,t)=>e+t*t,0),h=Math.sqrt(p/Math.max(d-2,1)),y=c.reduce((e,t)=>e+t[0],0)/d,f=c.reduce((e,t)=>e+Math.pow(t[0]-y,2),0),g=null!==(F=t.confidence)&&void 0!==F?F:.95,m=.99>g?.95>g?.9>g?1:1.645:1.96:2.576,b=null!==(H=t.steps)&&void 0!==H?H:5,v=c[d-1][0],x=(v-c[0][0])/Math.max(d-1,1),k=[];for(let e=1;b>=e;e++)k.push(v+e*x);const w=[];for(const e of k){const t=u(e),n=h*Math.sqrt(1+1/d+(f>0?Math.pow(e-y,2)/f:0))*m;w.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const A=`M${w.map(e=>`${s(e.x)},${l(e.yUpper)}`).join(" L")} L${w.slice().reverse().map(e=>`${s(e.x)},${l(e.yLower)}`).join(" L")} Z`,j=w.map(e=>`${s(e.x)},${l(e.yCenter)}`).join(" "),E=`${s(v)},${l(u(v))}`,O=t.strokeColor||"#6366f1";return e.createElement("g",{key:"ann-"+n},e.createElement("path",{d:A,fill:t.fill||"#6366f1",fillOpacity:null!==(q=t.fillOpacity)&&void 0!==q?q:.15,stroke:"none"}),e.createElement("polyline",{points:`${E} ${j}`,fill:"none",stroke:O,strokeWidth:null!==(G=t.strokeWidth)&&void 0!==G?G:2,strokeDasharray:null!==(V=t.strokeDasharray)&&void 0!==V?V:"6,3"}),t.label&&w.length>0&&e.createElement("text",{x:s(w[w.length-1].x)+4,y:l(w[w.length-1].yCenter)-4,fill:O,fontSize:11},t.label))}case"widget":{let r=null,i=null;if(null!=t.px&&null!=t.py)r=t.px,i=t.py;else{const e=Pe(t,n,o);if(!e)return null;r=e.x,i=e.y}if(null==r||null==i)return null;if(!Be(r,i,o))return null;const a=null!==(U=t.dx)&&void 0!==U?U:0,s=null!==(Z=t.dy)&&void 0!==Z?Z:0,l=null!==(Y=t.width)&&void 0!==Y?Y:32,c=null!==(X=t.height)&&void 0!==X?X:32,u=null!==(K=t.content)&&void 0!==K?K:e.createElement("span",{style:{fontSize:18,cursor:"default"},title:t.label||"Info"},"ℹ️");return e.createElement("foreignObject",{key:"ann-"+n,x:r+a-l/2,y:i+s-c/2,width:l,height:c,style:{overflow:"visible",pointerEvents:"auto"}},e.createElement("div",{style:{width:l,height:c,display:"flex",alignItems:"center",justifyContent:"center"}},u))}case"text":{const r=Pe(t,n,o);if(!r)return null;const{x:i,y:a}=r;return e.createElement("text",{key:"ann-text-"+n,x:i+(t.dx||0),y:a+(t.dy||0),fill:t.color||"var(--semiotic-text, #333)",fontSize:t.fontSize||11,dominantBaseline:"middle",style:{fontFamily:"inherit"}},t.label)}case"category-highlight":{const r=t.category;if(null==r)return null;const i=null===(J=o.scales)||void 0===J?void 0:J.o,a=null===(Q=o.scales)||void 0===Q?void 0:Q.x,s=null===(ee=o.scales)||void 0===ee?void 0:ee.y,l=(null==i?void 0:i.bandwidth)?i:(null==a?void 0:a.bandwidth)?a:(null==s?void 0:s.bandwidth)?s:null;if(!l)return null;const c=l(r);if(null==c)return null;const u=l.bandwidth(),d=t.color||"var(--semiotic-primary, #4589ff)",p=null!==(te=t.opacity)&&void 0!==te?te:.15,h=t.label;return(o.projection?"vertical"===o.projection:l===a)?e.createElement("g",{key:"ann-"+n},e.createElement("rect",{x:c,y:0,width:u,height:o.height||0,fill:d,fillOpacity:p}),h&&e.createElement("text",{x:c+u/2,y:12,textAnchor:"middle",fill:d,fontSize:12,fontWeight:"bold"},h)):e.createElement("g",{key:"ann-"+n},e.createElement("rect",{x:0,y:c,width:o.width||0,height:u,fill:d,fillOpacity:p}),h&&e.createElement("text",{x:12,y:c+u/2,dominantBaseline:"middle",fill:d,fontSize:12,fontWeight:"bold"},h))}default:return null}},n={scales:h?{x:h.x,y:h.y,time:h.x,value:h.y}:null,timeAxis:"x",xAccessor:T,yAccessor:R,width:l,height:c,data:_,frameType:"xy",pointNodes:F,curve:H,stickyPositionCache:K.current};return I.map((e,o)=>{if(N){const r=N(e,o,n);return null!=r?r:t(e,o,n)}return t(e,o,n)}).filter(Boolean)},[I,N,l,c,T,R,_,h,F,H]),te=function(e){var t;const n=i(e?Fe:qe,e?_e:Ge,e?_e:Ge);return e&&null!==(t=n.positions.get(e))&&void 0!==t?t:null}(G);return o(()=>{if(!(null==te?void 0:te.locked)||!G)return;const e=e=>{"Escape"===e.key&&We(G)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[null==te?void 0:te.locked,G]),y||w||A||z||L||ee&&ee.length>0||k||U||te?e.createElement("svg",{role:"img",width:u,height:d,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"}},e.createElement("title",null,"string"==typeof w?w:"XY Chart"),e.createElement("desc",null,"string"==typeof w?w+" — XY data visualization":"XY data visualization"),e.createElement("g",{transform:`translate(${p.left},${p.top})`},k&&h&&!q&&(()=>{var t,n;const o=Ve(null===(t=null==f?void 0:f.find(e=>"bottom"===e.orient))||void 0===t?void 0:t.gridStyle),r=Ve(null===(n=null==f?void 0:f.find(e=>"left"===e.orient))||void 0===n?void 0:n.gridStyle);return e.createElement("g",{className:"stream-grid"},Z.map((t,n)=>e.createElement("line",{key:"xgrid-"+n,x1:t.pixel,y1:0,x2:t.pixel,y2:c,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o})),Y.map((t,n)=>e.createElement("line",{key:"ygrid-"+n,x1:0,y1:t.pixel,x2:l,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r})))})(),y&&h&&(()=>{const t=null==f?void 0:f.find(e=>"left"===e.orient),n=null==f?void 0:f.find(e=>"bottom"===e.orient),o=!t||!1!==t.baseline,r=!n||!1!==n.baseline,i=(null==t?void 0:t.jaggedBase)||!1,a=(null==n?void 0:n.jaggedBase)||!1,s=null==n?void 0:n.landmarkTicks,u=null==t?void 0:t.landmarkTicks,d="var(--semiotic-border, #ccc)",h="var(--semiotic-text-secondary, var(--semiotic-text, #666))",y="var(--semiotic-text, #333)",v=!!(null==n?void 0:n.autoRotate)&&Z.length>1&&(()=>{const e=l/Math.max(Z.length-1,1);return Z.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:60),0)+8>e})();return e.createElement("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"}},!q&&r&&!a&&e.createElement("line",{x1:0,y1:c,x2:l,y2:c,stroke:d,strokeWidth:1}),!q&&a&&e.createElement("path",{d:Ue("bottom",l,c),fill:"none",stroke:d,strokeWidth:1}),Z.map((t,n)=>{const o=!!s&&("function"==typeof s?s(t.value,n):ge(t.value,n>0?Z[n-1].value:void 0));return e.createElement("g",{key:"xtick-"+n,transform:`translate(${t.pixel},${c})`},e.createElement("line",{y2:5,stroke:d,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?e.createElement("text",{y:v?10:18,textAnchor:v?"end":"middle",fontSize:o?11:10,fontWeight:o?600:400,fill:h,style:{userSelect:"none"},transform:v?"rotate(-45)":void 0},t.label):e.createElement("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"}},e.createElement("div",{style:{textAlign:"center",fontSize:10,userSelect:"none"}},t.label)))}),g&&e.createElement("text",{x:l/2,y:c+40,textAnchor:"middle",fontSize:12,fill:y,style:{userSelect:"none"}},g),!q&&o&&!i&&e.createElement("line",{x1:0,y1:0,x2:0,y2:c,stroke:d,strokeWidth:1}),!q&&i&&e.createElement("path",{d:Ue("left",l,c),fill:"none",stroke:d,strokeWidth:1}),Y.map((t,n)=>{const o=!!u&&("function"==typeof u?u(t.value,n):ge(t.value,n>0?Y[n-1].value:void 0));return e.createElement("g",{key:"ytick-"+n,transform:`translate(0,${t.pixel})`},e.createElement("line",{x2:-5,stroke:d,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?e.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:o?11:10,fontWeight:o?600:400,fill:h,style:{userSelect:"none"}},t.label):e.createElement("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"}},e.createElement("div",{style:{textAlign:"right",fontSize:10,userSelect:"none"}},t.label)))}),(()=>{const n=(null==t?void 0:t.label)||m;return n?e.createElement("text",{x:15-p.left,y:c/2,textAnchor:"middle",fontSize:12,fill:y,transform:`rotate(-90, ${15-p.left}, ${c/2})`,style:{userSelect:"none"}},n):null})(),(()=>{const t=null==f?void 0:f.find(e=>"right"===e.orient);if(!t||0===X.length)return null;const n=t.landmarkTicks,o=t.label||b;return e.createElement(e.Fragment,null,!1!==t.baseline&&e.createElement("line",{x1:l,y1:0,x2:l,y2:c,stroke:d,strokeWidth:1}),X.map((t,o)=>{const r=!!n&&("function"==typeof n?n(t.value,o):ge(t.value,o>0?X[o-1].value:void 0));return e.createElement("g",{key:"ytick-r-"+o,transform:`translate(${l},${t.pixel})`},e.createElement("line",{x2:5,stroke:d,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?e.createElement("text",{x:8,textAnchor:"start",dominantBaseline:"middle",fontSize:r?11:10,fontWeight:r?600:400,fill:h,style:{userSelect:"none"}},t.label):e.createElement("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"}},e.createElement("div",{style:{textAlign:"left",fontSize:10,userSelect:"none"}},t.label)))}),o&&e.createElement("text",{x:l+p.right-15,y:c/2,textAnchor:"middle",fontSize:12,fill:y,transform:`rotate(90, ${l+p.right-15}, ${c/2})`,style:{userSelect:"none"}},o))})())})(),ee,L&&h&&P&&B&&e.createElement(e.Fragment,null,L.top&&e.createElement("g",{transform:"translate(0, 0)"},e.createElement(Oe,{orient:"top",config:Ee(L.top),values:P,scale:h.x,size:p.top,length:l})),L.bottom&&e.createElement("g",{transform:`translate(0, ${c})`},e.createElement(Oe,{orient:"bottom",config:Ee(L.bottom),values:P,scale:h.x,size:p.bottom,length:l})),L.left&&e.createElement("g",{transform:"translate(0, 0)"},e.createElement(Oe,{orient:"left",config:Ee(L.left),values:B,scale:h.y,size:p.left,length:c})),L.right&&e.createElement("g",{transform:`translate(${l}, 0)`},e.createElement(Oe,{orient:"right",config:Ee(L.right),values:B,scale:h.y,size:p.right,length:c}))),z,te&&te.sourceId!==V&&(null==h?void 0:h.x)&&(()=>{const t=h.x(te.xValue);if(null==t||0>t||t>l)return null;const n=te.locked;return e.createElement("line",{x1:t,y1:0,x2:t,y2:c,stroke:n?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:n?1.5:1,strokeDasharray:n?"6,3":"4,4",pointerEvents:"none"})})(),U),w&&e.createElement("text",{x:u/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof w?w:null),function(t){const{legend:n,totalWidth:o,totalHeight:r,margin:i,legendPosition:a="right",title:s,legendHoverBehavior:l,legendClickBehavior:c,legendHighlightedCategory:u,legendIsolatedCategories:d,legendInteraction:p}=t;if(!n)return null;const h="top"===a||"bottom"===a;let y,f;return"left"===a?(y=4,f=i.top):"top"===a?(y=0,f=s?32:8):"bottom"===a?(y=0,f=r-i.bottom+50):(y=o-i.right+10,f=i.top),e.createElement("g",{transform:`translate(${y}, ${f})`},"object"==typeof(g=n)&&null!==g&&"gradient"in g?e.createElement(Ae,{config:n.gradient,orientation:h?"horizontal":"vertical",width:h?o:100}):function(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}(n)?e.createElement(je,{legendGroups:n.legendGroups,title:"",width:h?o:100,orientation:h?"horizontal":"vertical",customHoverBehavior:l,customClickBehavior:c,highlightedCategory:u,isolatedCategories:d,legendInteraction:p}):n);var g}({legend:A,totalWidth:u,totalHeight:d,margin:p,legendPosition:$,title:w,legendHoverBehavior:j,legendClickBehavior:E,legendHighlightedCategory:O,legendIsolatedCategories:C})):null}function Ke(e,t="#4e79a7"){return e&&"string"==typeof e?e:t}const Je="undefined"==typeof window||"undefined"==typeof document,Qe=e.createContext(null),et={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function tt(e,t){if(!e||0===e.length)return t+", empty";const n={};for(const t of e)n[t.type]=(n[t.type]||0)+1;const o=[],r={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks",wedge:"wedges",arc:"arcs",geoarea:"regions"},i=["point","line","area","rect","heatcell","circle","candlestick","wedge","arc","geoarea"],a=Object.keys(n).sort((e,t)=>{const n=i.indexOf(e),o=i.indexOf(t);return(-1===n?999:n)-(-1===o?999:o)});for(const e of a)o.push(`${n[e]} ${r[e]||e}`);return`${t}, ${o.join(", ")}`}const nt=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},ot={position:"absolute",top:0,left:0,right:0,zIndex:5,padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-text, #333)",background:"var(--semiotic-bg, #fff)",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},rt={marginBottom:8,paddingRight:28,color:"var(--semiotic-text-secondary, #666)",fontSize:12,letterSpacing:"0.01em"},it={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-border, #e0e0e0)",background:"var(--semiotic-bg, #fff)",cursor:"pointer",color:"var(--semiotic-text-secondary, #666)",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},at={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},st={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-border, #e0e0e0)",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-text-secondary, #666)"},lt={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},ct={textAlign:"left",fontSize:11,color:"var(--semiotic-text-secondary, #999)",marginBottom:4,fontStyle:"italic"};function ut({scene:t,chartType:n,tableId:o,chartTitle:r}){var i;const[a,s]=e.useState(!1),l=e.useContext(Qe),c=null!==(i=null==l?void 0:l.visible)&&void 0!==i&&i,u=a||c,d=e.useRef(null),p=r?"Data summary for "+r:o?`Data summary for ${n} ${o}`:"Data summary for "+n,h=e.useCallback(()=>{a||c||s(!0)},[a,c]),y=e.useCallback(e=>{var t;c||(null===(t=d.current)||void 0===t?void 0:t.contains(e.relatedTarget))||s(!1)},[c]);if(!t||0===t.length)return o?e.createElement("span",{id:o,tabIndex:-1,style:et}):null;if(!u)return e.createElement("div",{id:o,tabIndex:-1,onFocus:h,style:et,role:"region","aria-label":p},e.createElement("button",{type:"button",onClick:()=>s(!0)},"View data summary (",t.length," elements)"));const f=function(e){var t,n,o,r,i,a,s,l,c,u,d,p,h,y,f,g,m,b,v,x,k,w,A,j,E;const O=[];if(!Array.isArray(e))return O;for(const S of e)if(S&&"object"==typeof S)try{switch(S.type){case"point":O.push({label:"Point",values:{x:S.x,y:S.y}});break;case"line":{const e=S.path,t=Array.isArray(S.datum)?S.datum:[];if(!Array.isArray(e))break;for(let n=0;e.length>n&&t.length>n;n++){const t=e[n];Array.isArray(t)&&O.push({label:"Line point",values:{x:t[0],y:t[1]}})}break}case"area":{const e=S.topPath,t=Array.isArray(S.datum)?S.datum:[];if(!Array.isArray(e))break;for(let n=0;e.length>n&&t.length>n;n++){const t=e[n];Array.isArray(t)&&O.push({label:"Area point",values:{x:t[0],y:t[1]}})}break}case"rect":{const e=null!=S.datum&&"object"==typeof S.datum?S.datum:{},i=null!==(n=null!==(t=e.category)&&void 0!==t?t:S.group)&&void 0!==n?n:"",a=null!==(r=null!==(o=e.value)&&void 0!==o?o:e.__aggregateValue)&&void 0!==r?r:e.total;O.push({label:"Bar",values:{category:i,value:null!=a?a:""}});break}case"heatcell":O.push({label:"Cell",values:{x:S.x,y:S.y,value:S.value}});break;case"wedge":O.push({label:"Wedge",values:{category:null!==(l=null!==(a=null===(i=S.datum)||void 0===i?void 0:i.category)&&void 0!==a?a:null===(s=S.datum)||void 0===s?void 0:s.label)&&void 0!==l?l:"",value:null!==(u=null===(c=S.datum)||void 0===c?void 0:c.value)&&void 0!==u?u:""}});break;case"circle":O.push({label:"Node",values:{id:null!==(p=null===(d=S.datum)||void 0===d?void 0:d.id)&&void 0!==p?p:"",x:null!==(h=S.cx)&&void 0!==h?h:S.x,y:null!==(y=S.cy)&&void 0!==y?y:S.y}});break;case"arc":O.push({label:"Arc",values:{id:null!==(g=null===(f=S.datum)||void 0===f?void 0:f.id)&&void 0!==g?g:"",x:null!==(m=S.cx)&&void 0!==m?m:S.x,y:null!==(b=S.cy)&&void 0!==b?b:S.y}});break;case"candlestick":O.push({label:"Candlestick",values:{x:S.x,open:S.open,high:S.high,low:S.low,close:S.close}});break;case"geoarea":O.push({label:"Region",values:{name:null!==(A=null!==(k=null===(x=null===(v=S.datum)||void 0===v?void 0:v.properties)||void 0===x?void 0:x.name)&&void 0!==k?k:null===(w=S.datum)||void 0===w?void 0:w.name)&&void 0!==A?A:"",value:null!==(E=null===(j=S.datum)||void 0===j?void 0:j.value)&&void 0!==E?E:""}})}}catch(e){}return O}(t),g=function(e){if(!e||0===e.length)return[];const t=new Set;for(const n of e)if(n&&n.values)for(const e of Object.keys(n.values))t.add(e);const n=[];for(const o of t){const t=[],r=new Set;for(const n of e){if(!n||!n.values)continue;const e=n.values[o];null!=e&&""!==e&&("number"==typeof e&&!Number.isNaN(e)&&Number.isFinite(e)?t.push(e):"number"==typeof e||"object"!=typeof e&&"function"!=typeof e&&r.add(e+""))}if(t.length>0){let e=t[0],r=t[0],i=0;for(const n of t)e>n&&(e=n),n>r&&(r=n),i+=n;n.push({name:o,count:t.length,numeric:!0,min:e,max:r,mean:i/t.length})}else if(r.size>0){const e=Array.from(r);n.push({name:o,count:e.length,numeric:!1,uniqueValues:e.slice(0,5)})}}return n}(f),m=function(e,t){const n=[e+" data points."];for(const e of t)if(e.numeric)n.push(`${e.name}: ${nt(e.min)} to ${nt(e.max)}, mean ${nt(e.mean)}.`);else{const t=e.uniqueValues,o=t.length>3?`${t.slice(0,3).join(", ")}… (${e.count} unique)`:t.join(", ");n.push(`${e.name}: ${o}.`)}return n.join(" ")}(f.length,g),b=f.slice(0,5),v=new Set;for(const e of b)for(const t of Object.keys(e.values))v.add(t);const x=Array.from(v);return e.createElement("div",{ref:d,id:o,tabIndex:-1,onBlur:y,style:ot,role:"region","aria-label":p},e.createElement("button",{type:"button",onClick:()=>{c&&l&&l.setVisible(!1),s(!1)},"aria-label":"Close data summary",style:it},"×"),e.createElement("div",{role:"note",style:rt},m),e.createElement("table",{role:"table","aria-label":"Sample data for "+n,style:at},e.createElement("caption",{style:ct},"First ",b.length," of ",f.length," data points"),e.createElement("thead",null,e.createElement("tr",null,e.createElement("th",{style:st},"type"),x.map(t=>e.createElement("th",{key:t,style:st},t)))),e.createElement("tbody",null,b.map((t,n)=>e.createElement("tr",{key:n},e.createElement("td",{style:lt},t.label),x.map(n=>{return e.createElement("td",{key:n,style:lt},null==(o=t.values[n])||""===o?"—":"number"==typeof o?Number.isNaN(o)?"—":nt(o):"boolean"==typeof o?o?"true":"false":"object"==typeof o?"—":o+"");var o}))))))}function dt({summary:t}){return t?e.createElement("div",{role:"note",style:et},t):null}function pt({tableId:t}){return e.createElement("a",{href:"#"+t,style:et,onClick:e=>{e.preventDefault();const n=document.getElementById(t);n&&requestAnimationFrame(()=>n.focus())},onFocus:e=>{Object.assign(e.currentTarget.style,{position:"absolute",width:"auto",height:"auto",overflow:"visible",clip:"auto",whiteSpace:"normal",padding:"4px 8px",background:"var(--semiotic-bg, #fff)",color:"var(--semiotic-text, #000)",border:"2px solid var(--semiotic-focus, #005fcc)",borderRadius:"4px",zIndex:"10",fontSize:"12px",top:"4px",left:"4px"})},onBlur:e=>{const t=e.currentTarget;t.removeAttribute("style"),Object.assign(t.style,et)}},"Skip to data table")}function ht({hoverPoint:t}){let n="";if(t){const e=t.data||t;n="object"==typeof e?"Focused on data point: "+Object.entries(e).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Focused on data point: "+e}return e.createElement("div",{"aria-live":"polite","aria-atomic":"true",style:et},n)}const yt="var(--semiotic-focus, #005fcc)";function ft({active:t,hoverPoint:n,margin:o,size:r,shape:i="circle",width:a,height:s}){if(!t||!n)return null;const l=n.x+o.left,c=n.y+o.top;let u;if("rect"===i&&null!=a&&null!=s){const t=Math.max(a,4),n=Math.max(s,4);u=e.createElement("rect",{x:l-t/2-3,y:c-n/2-3,width:t+6,height:n+6,rx:3,fill:"none",stroke:yt,strokeWidth:2,strokeDasharray:"4,2"})}else u=e.createElement("circle","wedge"===i?{cx:l,cy:c,r:12,fill:"none",stroke:yt,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:l,cy:c,r:8,fill:"none",stroke:yt,strokeWidth:2,strokeDasharray:"4,2"});return e.createElement("svg",{style:{position:"absolute",left:0,top:0,width:r[0],height:r[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true"},u)}function gt({x:t,y:n,containerWidth:o,containerHeight:r,margin:i,children:a,className:s="stream-frame-tooltip",zIndex:l=1}){const c=e.useRef(null),[u,d]=e.useState(null);e.useLayoutEffect(()=>{const e=c.current;if(!e)return;const t=e.getBoundingClientRect();d(e=>e&&e.width===t.width&&e.height===t.height?e:{width:t.width,height:t.height})},[a,s,o,r]);let p;return p=u?`translate(${u.width+12>o-t?"calc(-100% - 12px)":"12px"}, ${u.height+12>r-n?"calc(-100% - 4px)":"4px"})`:`translate(${t>.7*o?"calc(-100% - 12px)":"12px"}, ${.3*r>n?"4px":"calc(-100% - 4px)"})`,e.createElement("div",{ref:c,className:s,style:{position:"absolute",left:i.left+t,top:i.top+n,transform:p,pointerEvents:"none",zIndex:l,width:"max-content"}},a)}const mt=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,bt=new WeakMap;function vt(e,t){var n,o;if(!t)return t;const r=mt.exec(t);if(!r)return t;const i=e.canvas;if(!i)return(null===(n=r[2])||void 0===n?void 0:n.trim())||t;let a=bt.get(i);if(a||(a=new Map,bt.set(i,a)),a.has(t))return a.get(t);const s=getComputedStyle(i).getPropertyValue(r[1]).trim()||(null===(o=r[2])||void 0===o?void 0:o.trim())||t;return a.set(t,s),s}function xt(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function kt(e,t,n=.6){var o,r,i,a,s;if(!xt(t))return;const l=null!==(o=t._pulseGlowRadius)&&void 0!==o?o:4,c=t.r+l*t._pulseIntensity,u=null!==(i=null!==(r=t.cx)&&void 0!==r?r:t.x)&&void 0!==i?i:0,d=null!==(s=null!==(a=t.cy)&&void 0!==a?a:t.y)&&void 0!==s?s:0;e.beginPath(),e.arc(u,d,c,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*n,e.stroke()}function wt(e,t,n,o=.35){xt(t)&&(e.globalAlpha=t._pulseIntensity*o,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",n?e.fill(n):e.fill())}function At(e){switch(e){case"monotoneX":return N;case"monotoneY":return I;case"cardinal":return $;case"catmullRom":return C;case"step":return B;case"stepBefore":return L;case"stepAfter":return P;case"basis":return z;case"natural":return R;default:return null}}function jt(e,t,n){let o=n;for(const n of t)"lesser"===n.thresholdType?n.value>e&&(o=n.color):e>n.value&&(o=n.color);return o}function Et(e,t,n,o,r,i){if(2>t.length)return;const a=[0];for(let e=1;t.length>e;e++){const n=t[e][0]-t[e-1][0],o=t[e][1]-t[e-1][1];a.push(a[e-1]+Math.sqrt(n*n+o*o))}const s=a[a.length-1];if(0===s)return;const l=Math.min(.2*s,40);e.strokeStyle=n,e.lineWidth=o,e.lineCap=i;for(let n=0;t.length-1>n;n++){const o=(a[n]+a[n+1])/2;let i=r;l>o&&(i*=o/l),l>s-o&&(i*=(s-o)/l),e.globalAlpha=Math.max(0,i),e.beginPath(),e.moveTo(t[n][0],t[n][1]),e.lineTo(t[n+1][0],t[n+1][1]),e.stroke()}}function Ot(e){return e.k}function St(e){return[e.x,e.y]}function Mt(e){return function(){return e}}function Ct([e,t,n]){const o=1<<n;return[e-Math.floor(e/o)*o,t-Math.floor(t/o)*o,n]}function $t(e,t,n,o){const r=e.getContext("2d");if(!r)return null;const i=t[0]*o,a=t[1]*o,s=t[0]+"px",l=t[1]+"px";return e.style.width!==s&&(e.style.width=s),e.style.height!==l&&(e.style.height=l),e.width===i&&e.height===a||(e.width=i,e.height=a),r.setTransform(o,0,0,o,0,0),r.translate(n.left,n.top),r}function zt(){return"undefined"!=typeof window&&window.devicePixelRatio||1}function Lt(e,t,n,o,r){return"function"==typeof e?e(t,n,o,r):e.replace("{z}",t+"").replace("{x}",n+"").replace("{y}",o+"").replace("{r}",r>1?"@2x":"")}class Pt{constructor(e=256){this.cache=new Map,this.limit=e}get(e){const t=this.cache.get(e);return t&&(t.lastUsed=performance.now()),t}set(e,t){this.cache.set(e,t),this.cache.size>this.limit&&this.evict()}evict(){for(;this.cache.size>this.limit;){let e,t=1/0;for(const[n,o]of this.cache)t>o.lastUsed&&(t=o.lastUsed,e=n);if(!e)break;{const t=this.cache.get(e);t&&(t.img.onload=null,t.img.onerror=null,t.img.src=""),this.cache.delete(e)}}}clear(){for(const e of this.cache.values())e.img.onload=null,e.img.onerror=null,e.img.src="";this.cache.clear()}}class Bt{constructor(e){this.capacity=e,this.particles=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,lineIndex:0,active:!1,x:0,y:0}}spawn(e){for(let t=0;this.capacity>t;t++){const n=this.particles[t];if(!n.active)return n.active=!0,n.t=0,n.offset=.6*(Math.random()-.5),n.lineIndex=e,n.x=0,n.y=0,n}return null}step(e,t,n,o){for(let r=0;this.capacity>r;r++){const i=this.particles[r];if(!i.active)continue;const a=n[i.lineIndex];if(!a||2>a.length){i.active=!1;continue}if(i.t+=e*t,i.t>=1){i.active=!1;continue}const s=It(a),l=Nt(a,i.t*s),c=(o[i.lineIndex]||2)/2;i.x=l.x+l.nx*i.offset*c*2,i.y=l.y+l.ny*i.offset*c*2}}countForLine(e){let t=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].lineIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1}}function It(e){let t=0;for(let n=1;e.length>n;n++){const o=e[n][0]-e[n-1][0],r=e[n][1]-e[n-1][1];t+=Math.sqrt(o*o+r*r)}return t}function Nt(e,t){let n=0;for(let o=1;e.length>o;o++){const r=e[o][0]-e[o-1][0],i=e[o][1]-e[o-1][1],a=Math.sqrt(r*r+i*i);if(n+a>=t||o===e.length-1){const s=a>0?(t-n)/a:0,l=a>.001?a:1;return{x:e[o-1][0]+r*s,y:e[o-1][1]+i*s,nx:-i/l,ny:r/l}}n+=a}const o=e[e.length-1];return{x:o[0],y:o[1],nx:0,ny:0}}function Dt(n){const o=a(null),c=Tt(n);return[function({children:t}){const i=r(()=>Tt(n),[]);return e.createElement(o.Provider,{value:i,children:t})},e=>{var n;const r=null!==(n=s(o))&&void 0!==n?n:c,a=t(e);a.current=e;const u=l(()=>a.current(r.getState()),[r]),d=l(()=>a.current(r.getState()),[r]);return i(r.subscribe,u,d)}]}function Tt(e){const t=new EventTarget;let n=e(function(e){n=Object.assign(Object.assign({},n),e(n)),t.dispatchEvent(new CustomEvent("update"))});return{getState:()=>n,subscribe:function(e){return t.addEventListener("update",e),()=>t.removeEventListener("update",e)}}}const Rt={mode:"light",colors:{primary:"#00a2ce",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",background:"transparent",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},Wt={mode:"dark",colors:{primary:"#4fc3f7",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",background:"#1a1a2e",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},_t={mode:"light",colors:{primary:"#0000cc",categorical:["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],sequential:"blues",diverging:"RdBu",background:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1},typography:{fontFamily:"system-ui, sans-serif",titleSize:18,labelSize:14,tickSize:12},tooltip:{background:"#000000",text:"#ffffff",borderRadius:"4px",fontSize:"14px",shadow:"0 2px 8px rgba(0, 0, 0, 0.3)"},borderRadius:"4px"},[Ft,Ht]=Dt(e=>({theme:Rt,setTheme(t){e(e=>{if("light"===t)return{theme:Rt};if("dark"===t)return{theme:Wt};if("high-contrast"===t)return{theme:_t};if(t.mode&&"auto"!==t.mode){const e="dark"===t.mode?Wt:Rt;return{theme:Object.assign(Object.assign(Object.assign({},e),t),{colors:Object.assign(Object.assign({},e.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.typography),t.typography||{})})}}return{theme:Object.assign(Object.assign(Object.assign({},e.theme),t),{colors:Object.assign(Object.assign({},e.theme.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.theme.typography),t.typography||{})})}})}})),qt={top:10,right:10,bottom:10,left:10},Gt={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"},Vt={width:28,height:28,border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,background:"rgba(255,255,255,0.9)",color:"#333",fontSize:16,fontWeight:600,lineHeight:1,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:0,boxShadow:"0 1px 3px rgba(0,0,0,0.1)"};function Ut({data:t}){if(!t)return null;if(t.properties)return e.createElement("div",{className:"semiotic-tooltip",style:Gt},e.createElement("div",{style:{fontWeight:600}},t.properties.name||t.properties.NAME||t.properties.id||"Feature"));const n=Object.entries(t).slice(0,3);return e.createElement("div",{className:"semiotic-tooltip",style:Gt},n.map(([t,n])=>e.createElement("div",{key:t},e.createElement("span",{style:{opacity:.7}},t,": "),e.createElement("span",{style:{fontWeight:600}},n+""))))}const Zt=c(function(i,a){var s,c,d,p,h,y,f,g,m,b;const{projection:v,projectionExtent:x,fitPadding:k,projectionTransform:w,areas:A,points:j,lines:E,xAccessor:O,yAccessor:S,lineDataAccessor:M,pointIdAccessor:C,lineType:$="geo",flowStyle:z="basic",graticule:L,zoomable:P,zoomExtent:B,onZoom:I,dragRotate:N,showParticles:D,particleStyle:R,tileURL:W,tileAttribution:q,tileCacheSize:G,size:V,width:U,height:Z,responsiveWidth:Y,responsiveHeight:X,margin:K,className:J,background:Q,areaStyle:ee,pointStyle:te,lineStyle:ne,colorScheme:oe,enableHover:re=!0,hoverAnnotation:ie,tooltipContent:ae,customClickBehavior:se,customHoverBehavior:le,annotations:ce,decay:ue,pulse:de,transition:pe,staleness:ye,backgroundGraphics:fe,foregroundGraphics:ge,title:be,legend:ve,legendPosition:xe,legendHoverBehavior:ke,legendClickBehavior:we,legendHighlightedCategory:Ae,legendIsolatedCategories:je,showAxes:Ee,accessibleTable:Oe=!0,description:Se,summary:Me}=i,Ce=function(){const[e,t]=n(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return o(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");return t(e.matches),function(e,t){return"function"==typeof e.addEventListener?(e.addEventListener("change",t),()=>e.removeEventListener("change",t)):(e.addListener(t),()=>e.removeListener(t))}(e,e=>t(e.matches))},[]),e}(),$e=t(Ce);$e.current=Ce;const ze="semiotic-table-"+e.useId(),Le=V||[U||600,Z||400],[Pe,Be]=function(e,r,i){const a=t(null),[s,l]=n(null);return o(()=>{if(!r&&!i)return;const e=a.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;l(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return t.observe(e),()=>t.disconnect()},[r,i]),[a,[r&&s?s.w:e[0],i&&s?s.h:e[1]]]}(Le,Y,X),Ie=r(()=>Object.assign(Object.assign({},qt),K),[K]),Ne=Be[0]-Ie.left-Ie.right,De=Be[1]-Ie.top-Ie.bottom,Te="function"==typeof ge?ge({size:Be,margin:Ie}):ge,Re="function"==typeof fe?fe({size:Be,margin:Ie}):fe,We=r(()=>null!=N?N:"orthographic"===("string"==typeof v?v:"object"==typeof v&&"type"in v?v.type:null),[N,v]),_e=r(()=>({projection:v,projectionExtent:x,fitPadding:k,xAccessor:O,yAccessor:S,lineDataAccessor:M,lineType:$,flowStyle:z,areaStyle:ee,pointStyle:te,lineStyle:ne,colorScheme:oe,graticule:L,projectionTransform:w,decay:ue,pulse:de,transition:pe,annotations:ce,pointIdAccessor:C}),[v,x,k,O,S,M,$,z,ee,te,ne,oe,L,w,ue,de,pe,ce,C]),Fe=t(null);Fe.current||(Fe.current=new he(_e));const He=t(null),qe=t(null),Ge=t(null),Ve=t(null),Ue=t(null);W&&!Ue.current&&(Ue.current=new Pt(G||256));const Ze=t(0),Ye=t(!0),Qe=Ht(e=>e.theme),et=t(ce),nt=t(()=>{}),ot=t(null),rt=t(_),it=t(!1),at=t(null),st=t(null),lt=t(null),ct=t(null),yt=t(0);if(D&&!ct.current){const e=null!==(s=null==R?void 0:R.maxPerLine)&&void 0!==s?s:30;ct.current=new Bt(50*e)}const mt=t(null),xt=t(null),[It,Nt]=n(null),[Dt,Tt]=n(0),[Rt,Wt]=n(!1),_t=l(()=>{Ze.current||(Ze.current=requestAnimationFrame(()=>nt.current()))},[]);o(()=>{qe.current&&bt.delete(qe.current),Ye.current=!0,_t()},[Qe,_t]),o(()=>{var e;null===(e=Fe.current)||void 0===e||e.updateConfig(_e),Ye.current=!0,_t()},[_e,_t]),o(()=>{const e=Fe.current;e&&(A&&e.setAreas(A),j&&e.setPoints(j),E&&e.setLines(E),Ye.current=!0,_t())},[A,j,E,_t]);const Ft=l(e=>{var t;null===(t=Fe.current)||void 0===t||t.pushPoint(e),Ye.current=!0,_t()},[_t]),Gt=l(e=>{var t;null===(t=Fe.current)||void 0===t||t.pushMany(e),Ye.current=!0,_t()},[_t]),Zt=l(()=>{var e;null===(e=Fe.current)||void 0===e||e.clear(),Ye.current=!0,_t()},[_t]);u(a,()=>({push:Ft,pushMany:Gt,removePoint:e=>{var t,n;const o=null!==(n=null===(t=Fe.current)||void 0===t?void 0:t.removePoint(e))&&void 0!==n?n:[];return o.length>0&&(Ye.current=!0,_t()),o},clear:Zt,getProjection:()=>{var e,t,n;return null!==(n=null===(t=null===(e=Fe.current)||void 0===e?void 0:e.scales)||void 0===t?void 0:t.projection)&&void 0!==n?n:null},getGeoPath:()=>{var e,t,n;return null!==(n=null===(t=null===(e=Fe.current)||void 0===e?void 0:e.scales)||void 0===t?void 0:t.geoPath)&&void 0!==n?n:null},getCartogramLayout:()=>{var e,t;return null!==(t=null===(e=Fe.current)||void 0===e?void 0:e.cartogramLayout)&&void 0!==t?t:null},getZoom:()=>rt.current.k,resetZoom:()=>{const e=at.current;e&&ot.current&&H(e).call(ot.current.transform,_)},getData:()=>{var e,t;return null!==(t=null===(e=Fe.current)||void 0===e?void 0:e.getPoints())&&void 0!==t?t:[]}}),[Ft,Gt,Zt,_t]);const Yt=t(()=>{});o(()=>{Yt.current=e=>{if(!re)return;const t=Fe.current;if(!t||!t.scene.length)return;const n=e.currentTarget.getBoundingClientRect(),o=e.clientX-n.left-Ie.left,r=e.clientY-n.top-Ie.top;if(0>o||o>Ne||0>r||r>De)return mt.current=null,xt.current=null,Nt(null),null==le||le(null),void _t();Ve.current||(Ve.current="undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(1,1):document.createElement("canvas"));const i=Ve.current.getContext("2d");if(!i)return;const a=me(t.scene,o,r,30,i);if(a){const e=a.node,t=e.datum,n=(null==t?void 0:t.properties)?t:(null==t?void 0:t.data)||t;let i,s;"point"===e.type?(i=e.x,s=e.y):"geoarea"===e.type?(i=e.centroid[0],s=e.centroid[1]):(i=o,s=r);const l=Object.assign(Object.assign(Object.assign({},n),(null==n?void 0:n.properties)||{}),{data:n,x:i,y:s,time:0});mt.current=l,xt.current=e,Nt(l),null==le||le({type:e.type,data:n,x:i,y:s}),_t()}else mt.current&&(mt.current=null,xt.current=null,Nt(null),null==le||le(null),_t())}},[re,Ne,De,Ie,le,_t]);const Xt=l(()=>{mt.current=null,xt.current=null,Nt(null),null==le||le(null),_t()},[le,_t]),Kt=l(e=>{if(!se)return;const t=Fe.current;if(!t||!t.scene.length)return;const n=e.currentTarget.getBoundingClientRect(),o=e.clientX-n.left-Ie.left,r=e.clientY-n.top-Ie.top;Ve.current||(Ve.current="undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(1,1):document.createElement("canvas"));const i=Ve.current.getContext("2d");if(!i)return;const a=me(t.scene,o,r,30,i);if(a){const e=a.node.datum;se({type:a.node.type,data:(null==e?void 0:e.properties)?e:(null==e?void 0:e.data)||e,x:o,y:r})}},[se,Ie]),Jt=t(-1),Qt=t(null),en=l(e=>{const t=Fe.current;if(!t||0===t.scene.length)return;const n=function(e){const t=[];for(const n of e)"point"===n.type&&null!=n.x?t.push({x:n.x,y:n.y,datum:n.datum,shape:"circle"}):"geoarea"===n.type&&n.centroid&&t.push({x:n.centroid[0],y:n.centroid[1],datum:n.datum,shape:"circle"});return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.scene);if(0===n.length)return;const o=Jt.current,r=function(e,t,n){switch(e){case"ArrowRight":case"ArrowDown":return n-1>t?t+1:t;case"ArrowLeft":case"ArrowUp":return t>0?t-1:t;case"PageDown":return Math.min(t+Math.max(1,Math.floor(.1*n)),n-1);case"PageUp":return Math.max(t-Math.max(1,Math.floor(.1*n)),0);case"Home":return 0;case"End":return n-1;case"Escape":return-1;default:return null}}(e.key,0>o?-1:o,n.length);if(null===r)return;if(e.preventDefault(),0>r)return Jt.current=-1,Qt.current=null,mt.current=null,xt.current=null,Nt(null),null==le||le(null),void _t();const i=0>o?0:r;Jt.current=i;const a=n[i];Qt.current={shape:a.shape,w:a.w,h:a.h};const s=function(e){const t=e.datum||{};return Object.assign(Object.assign({},"object"!=typeof t||null===t||Array.isArray(t)?{}:t),{data:t,x:e.x,y:e.y,time:e.x,value:e.y})}(a);mt.current=s,Nt(s);const l=a.datum;let c="point",u=l;l&&"object"==typeof l&&"geometry"in l&&(c="geoarea",l.properties&&"object"==typeof l.properties&&(u=Object.assign(Object.assign({},l),l.properties))),null==le||le({type:c,data:u,x:a.x,y:a.y}),_t()},[le,_t]),tn=l(e=>{Jt.current=-1,Qt.current=null,Yt.current(e)},[]);nt.current=()=>{var e,t,n,o,r,i,a;Ze.current=0;const s=qe.current,l=Fe.current;if(!s||!l)return;const c=performance.now();let u=!1;const d=lt.current;d&&(lt.current=null,l.applyRotation(d,{width:Ne,height:De}));const p=l.advanceTransition($e.current?c+1e6:c),h=!$e.current&&p;if(Ye.current&&!p){const e={width:Ne,height:De},t=We?l.getRotation():null;l.computeScene(e);const n=rt.current,o=1!==n.k||0!==n.x||0!==n.y;We&&t?o?(l.setRotation(t),l.applyZoomScale(n.k,e)):l.applyRotation(t,e):o&&l.applyZoomTransform(n,e),Ye.current=!1,s.setAttribute("aria-label",tt(l.scene,"Geographic chart"))}const y=zt();if(W&&Ue.current){const t=He.current;if(t&&(null===(e=l.scales)||void 0===e?void 0:e.projection)){const e=$t(t,Be,Ie,y);if(e){e.clearRect(-Ie.left,-Ie.top,Be[0],Be[1]),e.save(),e.beginPath(),e.rect(0,0,Ne,De),e.clip();const t=function(e,t){const{tileURL:n,projection:o,width:r,height:i,tileCache:a,onTileLoad:s}=t,l=o.scale(),c=o.translate(),u=2*l*Math.PI,d=function(){let e=0,t=0,n=960,o=500,r=!0,i=!0,a=256,s=Ot,l=St,c=0;function u(){const u=+s.apply(this,arguments),d=l.apply(this,arguments),p=Math.log2(u/a),h=Math.round(Math.max(p+c,0)),y=Math.pow(2,p-h)*a,f=+d[0]-u/2,g=+d[1]-u/2,m=Math.max(r?0:-1/0,Math.floor((e-f)/y)),b=Math.min(r?1<<h:1/0,Math.ceil((n-f)/y)),v=Math.max(i?0:-1/0,Math.floor((t-g)/y)),x=Math.min(i?1<<h:1/0,Math.ceil((o-g)/y)),k=[];for(let e=v;x>e;++e)for(let t=m;b>t;++t)k.push([t,e,h]);return k.translate=[f/y,g/y],k.scale=y,k}return u.size=function(r){return arguments.length?(e=t=0,n=+r[0],o=+r[1],u):[n-e,o-t]},u.extent=function(r){return arguments.length?(e=+r[0][0],t=+r[0][1],n=+r[1][0],o=+r[1][1],u):[[e,t],[n,o]]},u.scale=function(e){return arguments.length?(s="function"==typeof e?e:Mt(+e),u):s},u.translate=function(e){return arguments.length?(l="function"==typeof e?e:Mt([+e[0],+e[1]]),u):l},u.zoomDelta=function(e){return arguments.length?(c=+e,u):c},u.tileSize=function(e){return arguments.length?(a=+e,u):a},u.clamp=function(e){return arguments.length?(r=i=!!e,u):r&&i},u.clampX=function(e){return arguments.length?(r=!!e,u):r},u.clampY=function(e){return arguments.length?(i=!!e,u):i},u}().size([r,i]).scale(u).translate(c).clamp(!0)(),p=zt();let h=!0;for(const t of d){const[o,r,i]=Ct(t),l=`${i}/${o}/${r}`;let c=a.get(l);if(!c){const e=new Image;e.crossOrigin="anonymous";const t={img:e,loaded:!1,key:l,lastUsed:performance.now()};a.set(l,t),e.onload=()=>{t.loaded=!0,null==s||s()},e.onerror=()=>{t.loaded=!0},e.src=Lt(n,i,o,r,p),c=t}if(!c.loaded){h=!1;continue}const u=d.scale;e.drawImage(c.img,(t[0]+d.translate[0])*u-.5,(t[1]+d.translate[1])*u-.5,u+1,u+1)}return h}(e,{tileURL:W,projection:l.scales.projection,width:Ne,height:De,tileCache:Ue.current,onTileLoad:()=>_t()});e.restore(),t||(u=!0)}}}const f=$t(s,Be,Ie,y);if(!f)return;f.clearRect(-Ie.left,-Ie.top,Be[0],Be[1]),Q&&!W&&(f.fillStyle=Q,f.fillRect(0,0,Ne,De)),f.save(),f.beginPath(),f.rect(0,0,Ne,De),f.clip();const g=l.scene,m={height:De};if(function(e,t){var n,o,r;const i=t.filter(e=>"geoarea"===e.type);for(const t of i){if(!t.pathData)continue;const i=new Path2D(t.pathData),a=t.style.fill||"#e0e0e0";if("none"!==a&&(e.fillStyle=a,e.globalAlpha=(null!==(n=t._decayOpacity)&&void 0!==n?n:1)*(null!==(o=t.style.fillOpacity)&&void 0!==o?o:1),e.fill(i)),t.style.stroke&&"none"!==t.style.stroke){if(e.strokeStyle=vt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||.5,e.globalAlpha=null!==(r=t._decayOpacity)&&void 0!==r?r:1,t.style.strokeDasharray){const n=t.style.strokeDasharray.split(",").map(Number);e.setLineDash(n)}else e.setLineDash([]);e.stroke(i)}wt(e,t,i),e.globalAlpha=1,e.setLineDash([])}}(f,g),((e,t,n,o)=>{var r,i;const a=t.filter(e=>"line"===e.type);for(const s of a){if(2>s.path.length)continue;const l=s.style.stroke||"#007bff",c=s.style.strokeWidth||2,u=s.colorThresholds,d=s.rawValues;if(e.setLineDash(s.style.strokeDasharray?s.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=s.style.opacity&&(e.globalAlpha=s.style.opacity),e.lineWidth=c,e.lineCap=s.style.strokeLinecap||"butt",s.style._edgeFade){const f=null!==(r=s.style.opacity)&&void 0!==r?r:1;Et(e,s.path,l,c,f,s.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const p=At(s.curve),h=u&&u.length>0&&d&&d.length===s.path.length,y=s._decayOpacities;if(y&&y.length===s.path.length&&!h){e.strokeStyle=l;const g=null!==(i=s.style.opacity)&&void 0!==i?i:1;for(let m=0;s.path.length-1>m;m++)e.globalAlpha=.5*(y[m]+y[m+1])*g,e.beginPath(),e.moveTo(s.path[m][0],s.path[m][1]),e.lineTo(s.path[m+1][0],s.path[m+1][1]),e.stroke()}else if(h){let b=null,v=null,x=null,k=null,w=!1;function A(t,n,o){e.beginPath(),e.strokeStyle=t,e.moveTo(n,o),w=!0}function j(){w&&(e.stroke(),w=!1)}for(let E=0;s.path.length>E;E++){const[O,S]=s.path[E],M=d[E],C=jt(M,u,l);if(null!==b&&null!==k&&null!==x){if(C===k)e.lineTo(O,S);else{const $=[];for(const z of u){const L=z.value;(x>L||L>M)&&(L>x||M>L)||x===L||M===L||$.push({t:(L-x)/(M-x)})}$.sort((e,t)=>e.t-t.t);for(const P of $){const B=b+(O-b)*P.t,I=v+(S-v)*P.t,N=jt(x+(M-x)*Math.min(P.t+1e-4,1),u,l);e.lineTo(B,I),j(),A(N,B,I)}e.lineTo(O,S)}b=O,v=S,x=M,k=C}else A(C,O,S),b=O,v=S,x=M,k=C}j()}else{if(e.beginPath(),!s.strokeGradient||2>s.strokeGradient.colorStops.length||2>s.path.length)e.strokeStyle=l;else{const D=e.createLinearGradient(s.path[0][0],0,s.path[s.path.length-1][0],0);for(const R of s.strokeGradient.colorStops)D.addColorStop(Math.max(0,Math.min(1,R.offset)),R.color);e.strokeStyle=D}if(p)T().x(e=>e[0]).y(e=>e[1]).curve(p).context(e)(s.path);else{const[W,_]=s.path[0];e.moveTo(W,_);for(let F=1;s.path.length>F;F++)e.lineTo(s.path[F][0],s.path[F][1])}e.stroke()}if(s.style.fill&&s.style.fillOpacity&&s.style.fillOpacity>0){if(e.beginPath(),e.globalAlpha=s.style.fillOpacity,e.fillStyle=("string"==typeof s.style.fill?vt(e,s.style.fill):s.style.fill)||s.style.fill,p&&!h)T().x(e=>e[0]).y(e=>e[1]).curve(p).context(e)(s.path);else{const[q,G]=s.path[0];e.moveTo(q,G);for(let V=1;s.path.length>V;V++)e.lineTo(s.path[V][0],s.path[V][1])}const H=s.path[0][0];e.lineTo(s.path[s.path.length-1][0],o.height),e.lineTo(H,o.height),e.closePath(),e.fill()}e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}})(f,g,0,m),((e,t)=>{var n;const o=t.filter(e=>"point"===e.type);if(0!==o.length){e.save();try{for(const t of o){e.beginPath(),e.arc(t.x,t.y,t.r,0,2*Math.PI);const o=null!==(n=t.style.opacity)&&void 0!==n?n:t.style.fillOpacity;null!=o&&(e.globalAlpha=o),e.fillStyle=("string"==typeof t.style.fill?vt(e,t.style.fill):t.style.fill)||"#4e79a7",e.fill(),t.style.stroke&&(e.strokeStyle=("string"==typeof t.style.stroke?vt(e,t.style.stroke):t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),kt(e,t),e.globalAlpha=1}}finally{e.restore()}}})(f,g),D&&ct.current){const e=ct.current,a=g.filter(e=>"line"===e.type);if(a.length>0){const s=R||{},l=.3*(null!==(t=s.speedMultiplier)&&void 0!==t?t:1),d=null!==(n=s.maxPerLine)&&void 0!==n?n:30,p=null!==(o=s.spawnRate)&&void 0!==o?o:.15,h=null!==(r=s.radius)&&void 0!==r?r:2,y=null!==(i=s.opacity)&&void 0!==i?i:.7,g=c/1e3,m=yt.current>0?Math.min(g-yt.current,.1):.016;yt.current=g;const b=a.map(e=>e.path),v=a.map(e=>e.style.strokeWidth||2);for(let t=0;a.length>t;t++)Math.random()<p&&e.countForLine(t)<d&&e.spawn(t);e.step(m,l,b,v),f.globalAlpha=y;for(let t=0;e.particles.length>t;t++){const n=e.particles[t];if(!n.active)continue;const o=a[n.lineIndex],r="function"==typeof s.color?s.color(null==o?void 0:o.datum):"source"!==s.color&&s.color?s.color:(null==o?void 0:o.style.stroke)||"#fff";f.beginPath(),f.arc(n.x,n.y,h,0,2*Math.PI),f.fillStyle=r,f.fill()}f.globalAlpha=1,u=!0}}f.restore();const b=Ge.current;if(b){const e=$t(b,Be,Ie,y);if(e){e.clearRect(-Ie.left,-Ie.top,Be[0],Be[1]);const t=xt.current;if(t&&"geoarea"===t.type){const n=new Path2D(t.pathData);e.fillStyle="rgba(255, 255, 255, 0.3)",e.fill(n),e.strokeStyle="rgba(0, 0, 0, 0.5)",e.lineWidth=2,e.stroke(n)}if(t&&"point"===t.type){const n=t,o="object"==typeof ie?ie:void 0,r=(null==o?void 0:o.pointColor)||function(e){if(!e)return null;if("heatcell"===e.type)return e.fill||null;if("candlestick"===e.type)return e.isUp?e.upColor:e.downColor;const{style:t}=e;if(!t)return null;const n="string"==typeof t.fill?t.fill:null;return"line"===e.type||"area"===e.type?t.stroke||n||null:n||t.stroke||null}(t);e.beginPath(),e.arc(n.x,n.y,n.r+3,0,2*Math.PI),r?(e.save(),e.globalAlpha=.4,e.fillStyle=r,e.fill(),e.restore()):(e.fillStyle="rgba(255, 255, 255, 0.4)",e.fill()),e.strokeStyle=r||"rgba(0, 0, 0, 0.5)",e.lineWidth=2,e.stroke()}}}if(ye){const e=performance.now()-l.lastIngestTime>(null!==(a=ye.threshold)&&void 0!==a?a:5e3);e!==Rt&&Wt(e)}const v=ce!==et.current;v&&(et.current=ce),(Ye.current||v)&&Tt(e=>e+1),(h||l.hasActivePulses||u)&&(Ze.current=requestAnimationFrame(()=>nt.current()))},o(()=>(_t(),()=>{var e;Ze.current&&(cancelAnimationFrame(Ze.current),Ze.current=0),null===(e=Ue.current)||void 0===e||e.clear()}),[_t]),o(()=>{Ye.current=!0,_t()},[Ne,De,Q,_t]),function(e,t,n,r,i,a){o(()=>{if(!e)return;const o=setInterval(()=>{var o;const s=t.current;if(!s||0===s.lastIngestTime)return;const l="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(o=e.threshold)&&void 0!==o?o:5e3,u=l-s.lastIngestTime>c;u!==i&&(a(u),n.current=!0,r())},1e3);return()=>clearInterval(o)},[e,i,r])}(ye,Fe,Ye,_t,Rt,Wt),o(()=>{if("production"!==process.env.NODE_ENV&&W){const e="string"==typeof v?v:"object"==typeof v&&"type"in v?v.type:null;e&&"mercator"!==e&&console.warn(`[StreamGeoFrame] tileURL is set but projection is "${e}". Raster tiles use Web Mercator and will not align with other projections.`)}},[W,v]),o(()=>{const e=at.current;if(!P||!e)return ot.current&&e&&(H(e).on(".zoom",null),ot.current=null),void(e&&H(e).on("mousedown.rotate",null).on("touchstart.rotate",null));const[t,n]=B||[1,8],o={width:Ne,height:De};if(We){let r=rt.current.k;const i=e=>{var i;r=Math.max(t,Math.min(n,e)),rt.current=_.scale(r);const a=Fe.current;a&&(a.applyZoomScale(r,o),Ye.current=!1,_t(),null==I||I({projection:null===(i=a.scales)||void 0===i?void 0:i.projection,zoom:a.currentZoom}))};ot.current={scaleBy:(e,t)=>i(r*t),transform:(e,t)=>{var n;return i(null!==(n=null==t?void 0:t.k)&&void 0!==n?n:1)}};const a=e=>{e.preventDefault(),i(r*(0>e.deltaY?1.1:1/1.1))},s=e=>{const t=e.target;t&&(t.closest("button")||t.closest(".stream-geo-zoom-controls"))||(e.preventDefault(),i(1.5*r))};e.addEventListener("wheel",a,{passive:!1}),e.addEventListener("dblclick",s);const l=.4,c=t=>{if(0!==t.button)return;const n=t.target;if(n.closest("button")||n.closest(".stream-geo-zoom-controls"))return;const o=Fe.current;if(!o)return;const r=o.getRotation();st.current={x:t.clientX,y:t.clientY,rotation:[...r]},e.setPointerCapture(t.pointerId),t.preventDefault()},u=e=>{const t=st.current;t&&(lt.current=[t.rotation[0]+(e.clientX-t.x)*l,Math.max(-90,Math.min(90,t.rotation[1]-(e.clientY-t.y)*l)),t.rotation[2]],_t())},d=t=>{var n;if(!st.current)return;st.current=null,e.releasePointerCapture(t.pointerId);const r=lt.current;if(r){lt.current=null;const e=Fe.current;e&&(e.applyRotation(r,o),_t())}const i=Fe.current;i&&(null==I||I({projection:null===(n=i.scales)||void 0===n?void 0:n.projection,zoom:i.currentZoom}))};return e.addEventListener("pointerdown",c),e.addEventListener("pointermove",u),e.addEventListener("pointerup",d),e.addEventListener("pointercancel",d),()=>{e.removeEventListener("wheel",a),e.removeEventListener("dblclick",s),e.removeEventListener("pointerdown",c),e.removeEventListener("pointermove",u),e.removeEventListener("pointerup",d),e.removeEventListener("pointercancel",d),ot.current=null}}const r=F().scaleExtent([t,n]).extent([[0,0],[Be[0],Be[1]]]).translateExtent([[-1/0,-1/0],[1/0,1/0]]).on("zoom",e=>{const t=e.transform;rt.current=t,it.current=!0;const n=Fe.current;n&&(n.applyZoomTransform(t,o),Ye.current=!1,_t())}).on("end",e=>{var t;rt.current=e.transform,it.current=!1;const n=Fe.current;n&&(null==I||I({projection:null===(t=n.scales)||void 0===t?void 0:t.projection,zoom:n.currentZoom}))});return ot.current=r,H(e).call(r),()=>{H(e).on(".zoom",null)}},[P,B,We,Be,Ne,De,Ie,I,_t]);const nn=re&&!1!==ie,on=nn&&It?ae?ae(It):e.createElement(Ut,{data:It}):null,rn=on?e.createElement(gt,{x:It.x,y:It.y,containerWidth:Ne,containerHeight:De,margin:Ie,className:"stream-frame-tooltip",zIndex:10},on):null;if(Je){const t=Fe.current;t&&(A||j||E)&&(A&&t.setAreas(A),j&&t.setPoints(j),E&&t.setLines(E),t.computeScene({width:Ne,height:De}));const n=null!==(c=null==t?void 0:t.scene)&&void 0!==c?c:[];return e.createElement("div",{className:"stream-geo-frame"+(J?" "+J:""),role:"img","aria-label":Se||("string"==typeof be?be:"Geographic chart"),style:{position:"relative",width:Be[0],height:Be[1]}},e.createElement(dt,{summary:Me}),e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:Be[0],height:Be[1],style:{position:"absolute",left:0,top:0}},e.createElement("g",{transform:`translate(${Ie.left},${Ie.top})`},Re),e.createElement("g",{transform:`translate(${Ie.left},${Ie.top})`},Q&&e.createElement("rect",{x:0,y:0,width:Ne,height:De,fill:Q}),n.map((t,n)=>function(t,n){var o,r,i,a,s,l;switch(t.type){case"geoarea":{const i=t;return i.pathData?e.createElement("path",{key:"geoarea-"+n,d:i.pathData,fill:Ke(i.style.fill,"#e0e0e0"),fillOpacity:null!==(o=i.style.fillOpacity)&&void 0!==o?o:1,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth||.5,strokeDasharray:i.style.strokeDasharray,opacity:null!==(r=i._decayOpacity)&&void 0!==r?r:1}):null}case"point":{const o=t;return e.createElement("circle",{key:"point-"+n,cx:o.x,cy:o.y,r:o.r,fill:Ke(o.style.fill),fillOpacity:null!==(i=o.style.fillOpacity)&&void 0!==i?i:.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:null!==(a=o._decayOpacity)&&void 0!==a?a:null!==(s=o.style.opacity)&&void 0!==s?s:1})}case"line":{const o=t;if(2>o.path.length)return null;const r="M"+o.path.map(e=>`${e[0]},${e[1]}`).join("L");return e.createElement("path",{key:"line-"+n,d:r,fill:"none",stroke:o.style.stroke||"#4e79a7",strokeWidth:o.style.strokeWidth||1.5,strokeDasharray:o.style.strokeDasharray,opacity:null!==(l=o.style.opacity)&&void 0!==l?l:1})}default:return null}}(t,n)))),e.createElement(Xe,{width:Ne,height:De,totalWidth:Be[0],totalHeight:Be[1],margin:Ie,scales:null,showAxes:!1,title:be,legend:ve,legendPosition:xe,legendHoverBehavior:ke,legendClickBehavior:we,legendHighlightedCategory:Ae,legendIsolatedCategories:je,foregroundGraphics:Te,annotations:ce,annotationFrame:0,xValues:[],yValues:[],pointNodes:n.filter(e=>"point"===e.type)}))}const an=l(e=>{at.current=e,Pe&&"object"==typeof Pe&&(Pe.current=e)},[Pe]);return e.createElement("div",{ref:an,className:"stream-geo-frame"+(J?" "+J:""),role:"group","aria-label":Se||("string"==typeof be?be:"Geographic chart"),tabIndex:0,style:Object.assign({position:"relative",width:Y?"100%":Be[0],height:X?"100%":Be[1],overflow:"hidden"},P?{touchAction:"none"}:{}),onKeyDown:en},Oe&&e.createElement(pt,{tableId:ze}),Oe&&e.createElement(ut,{scene:null!==(p=null===(d=Fe.current)||void 0===d?void 0:d.scene)&&void 0!==p?p:[],chartType:"Geographic chart",tableId:ze,chartTitle:"string"==typeof be?be:void 0}),e.createElement(dt,{summary:Me}),e.createElement("div",{role:"img","aria-label":Se||("string"==typeof be?be:"Geographic chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:nn?tn:void 0,onMouseLeave:nn?Xt:void 0,onClick:se?Kt:void 0},Re&&e.createElement("svg",{style:{position:"absolute",left:0,top:0,width:Be[0],height:Be[1],pointerEvents:"none"}},e.createElement("g",{transform:`translate(${Ie.left},${Ie.top})`},Re)),W&&e.createElement("canvas",{ref:He,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),e.createElement("canvas",{ref:qe,"aria-label":tt(null!==(y=null===(h=Fe.current)||void 0===h?void 0:h.scene)&&void 0!==y?y:[],"Geographic chart"),style:{position:"absolute",left:0,top:0}}),e.createElement("canvas",{ref:Ge,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),e.createElement(ht,{hoverPoint:It}),e.createElement(Xe,{width:Ne,height:De,totalWidth:Be[0],totalHeight:Be[1],margin:Ie,scales:null,showAxes:null!=Ee&&Ee,title:be,legend:ve,legendPosition:xe,legendHoverBehavior:ke,legendClickBehavior:we,legendHighlightedCategory:Ae,legendIsolatedCategories:je,foregroundGraphics:Te,annotations:ce,annotationFrame:Dt,xValues:[],yValues:[],pointNodes:null===(f=Fe.current)||void 0===f?void 0:f.scene.filter(e=>"point"===e.type)}),(null==ye?void 0:ye.showBadge)&&e.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===ye.badgePosition?{top:4,left:4}:"bottom-left"===ye.badgePosition?{bottom:4,left:4}:"bottom-right"===ye.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:Rt?"#dc3545":"#28a745",color:"white"})},Rt?"STALE":"LIVE"),P&&e.createElement("div",{className:"stream-geo-zoom-controls",style:{position:"absolute",bottom:Ie.bottom+8,left:Ie.left+8,display:"flex",flexDirection:"column",gap:2,zIndex:2}},e.createElement("button",{type:"button","aria-label":"Zoom in",onClick:e=>{e.stopPropagation();const t=at.current,n=ot.current;t&&(null==n?void 0:n.scaleBy)&&n.scaleBy(H(t),1.5)},style:Vt},"+"),e.createElement("button",{type:"button","aria-label":"Zoom out",onClick:e=>{e.stopPropagation();const t=at.current,n=ot.current;t&&(null==n?void 0:n.scaleBy)&&n.scaleBy(H(t),1/1.5)},style:Vt},"−")),q&&e.createElement("div",{className:"stream-geo-tile-attribution",style:{position:"absolute",bottom:Ie.bottom+2,right:Ie.right+4,fontSize:10,color:"rgba(0,0,0,0.6)",background:"rgba(255,255,255,0.7)",padding:"1px 4px",borderRadius:2,pointerEvents:"none",zIndex:2}},q),e.createElement(ft,{active:Jt.current>=0,hoverPoint:It,margin:Ie,size:Be,shape:null===(g=Qt.current)||void 0===g?void 0:g.shape,width:null===(m=Qt.current)||void 0===m?void 0:m.w,height:null===(b=Qt.current)||void 0===b?void 0:b.h}),rn))});Zt.displayName="StreamGeoFrame";const Yt={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, white)",padding:"8px 12px",borderRadius:"var(--semiotic-tooltip-radius, 6px)",fontSize:"var(--semiotic-tooltip-font-size, 14px)",fontFamily:"var(--semiotic-font-family, inherit)",lineHeight:"1.5",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.15))",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function Xt(e,t){return"function"==typeof t?t(e):e[t]}function Kt(e,t){if(t)return t(e);if(null==e)return"";if("number"==typeof e){if(!Number.isFinite(e))return e+"";const t=Number.isInteger(e)?e:parseFloat(e.toPrecision(6));return Math.abs(t)>9999?t.toLocaleString():t+""}return e instanceof Date?e.toLocaleDateString():"object"==typeof e&&null!==e?void 0!==e.id?e.id+"":void 0!==e.name?e.name+"":JSON.stringify(e):e+""}function Jt(t={}){const{fields:n,title:o,format:r,style:i={},className:a=""}=t;return t=>{if(!t||"object"!=typeof t)return null;let s;const l=[];if(o){const e=Xt(t,o);s=Kt(e,r)}if(n&&n.length>0)n.forEach(e=>{let n,o,i;"string"==typeof e?(n=e,o=e,i=r):(n=e.label,o=e.accessor||e.key||"",i=e.format||r);const a=Xt(t,o);l.push({label:n,value:Kt(a,i)})});else if(!o){const e=["value","y","name","id","label"];for(const n of e)if(void 0!==t[n]){s=Kt(t[n],r);break}if(!s){const e=Object.keys(t).filter(e=>!e.startsWith("_"));e.length>0&&(s=Kt(t[e[0]],r))}}const c=Object.assign(Object.assign({},Yt),i);return e.createElement("div",{className:("semiotic-tooltip "+a).trim(),style:c},s&&e.createElement("div",{style:{fontWeight:l.length>0?"bold":"normal"}},s),l.map((t,n)=>e.createElement("div",{key:n,style:{marginTop:0===n&&s?"4px":0}},t.label&&e.createElement("span",null,t.label,": "),t.value)))}}function Qt(t){if(!0===t)return Jt();if("function"==typeof t){const n=t;return t=>{const o=n(!t||"object"!=typeof t.data||null===t.data||"node"!==t.type&&"edge"!==t.type?t:t.data);return null==o?null:e.createElement("div",{className:"semiotic-tooltip",style:Yt},o)}}return!1!==t&&void 0!==t&&("object"==typeof t&&null!==t&&("fields"in t||"title"in t)?Jt(t):Jt())}const en={category10:q,tableau10:Q,set3:J,blues:K,reds:X,greens:Y,oranges:Z,purples:U,viridis:V,plasma:G},tn=q,nn=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],on=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function rn(e,t,n){if("function"==typeof t){const o=t(e);return n&&o&&"string"==typeof o&&!function(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||on.has(t)}(o)?n(o):o}const o=null==e?void 0:e[t];return n?n(o):tn[Math.abs(function(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n),t&=t;return Math.abs(t)}(o+""))%tn.length]}function an(e,t,n="category10"){const o=Array.from(new Set(e.map(e=>null==e?void 0:e[t]).filter(e=>null!=e))),r=o.every(e=>"number"==typeof e||!isNaN(Number(e)));if(Array.isArray(n))return A().domain(o).range(n).unknown("#999");const i=en[n]||en.category10;if(r&&"function"==typeof i){let e=-1/0;for(const t of o){const n=Number(t);n>e&&(e=n)}return t=>i(Number(t)/e)}{const e=Array.isArray(i)?i:tn;return A().domain(o).range(e).unknown("#999")}}function sn(e,t,n=[3,20],o){let r;if(r="function"==typeof t?t(e):null==e?void 0:e[t],!o)return r;const[i,a]=o,[s,l]=n;return a===i?(s+l)/2:s+(r-i)/(a-i)*(l-s)}const ln=a(null);function cn(e){const t=[];for(const[n,o]of Object.entries(e.fields))if("point"===o.type)t.push(e=>o.values.has(e[n]));else{const[e,r]=o.range;t.push(t=>{const o=t[n];return o>=e&&r>=o})}return e=>t.every(t=>t(e))}function un(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}const[dn,pn]=Dt(e=>({selections:new Map,setClause(t,n){e(e=>{const o=new Map(e.selections),r=un(o,t),i=new Map(r.clauses);return i.set(n.clientId,n),o.set(t,Object.assign(Object.assign({},r),{clauses:i})),{selections:o}})},clearClause(t,n){e(e=>{const o=e.selections.get(t);if(!o)return{};const r=new Map(e.selections),i=new Map(o.clauses);return i.delete(n),r.set(t,Object.assign(Object.assign({},o),{clauses:i})),{selections:r}})},setResolution(t,n){e(e=>{const o=new Map(e.selections),r=un(o,t);return o.set(t,Object.assign(Object.assign({},r),{resolution:n})),{selections:o}})},clearSelection(t){e(e=>{const n=new Map(e.selections),o=n.get(t);return o&&n.set(t,Object.assign(Object.assign({},o),{clauses:new Map})),{selections:n}})}})),[hn,yn]=Dt(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const n=e.observations;return n.push(t),n.length>e.maxObservations&&n.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}}));function fn(e){const t=d(),n=e.clientId||t,{name:o}=e,i=pn(e=>e.selections.get(o)),a=pn(e=>e.setClause),s=pn(e=>e.clearClause),c=r(()=>!!i&&i.clauses.size>0,[i]);return{predicate:r(()=>i&&0!==i.clauses.size?function(e,t){const n=[];for(const[o,r]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(cn(r));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(i,n):()=>!0,[i,n]),isActive:c,selectPoints:l(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"point",values:new Set(o)};a(o,{clientId:n,type:"point",fields:t})},[n,o,a]),selectInterval:l(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"interval",range:o};a(o,{clientId:n,type:"interval",fields:t})},[n,o,a]),clear:l(()=>{s(o,n)},[s,o,n]),clientId:n}}function gn(e){const t=e.name||"hover",{fields:n}=e,{predicate:o,isActive:r,selectPoints:i,clear:a}=fn({name:t});return{onHover:l(e=>{if(!e)return void a();const t={};for(const o of n){const n=e[o];void 0!==n&&(t[o]=[n])}Object.keys(t).length>0&&i(t)},[n,i,a,t]),predicate:o,isActive:r}}const mn=a(!1);function bn(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields||t||[],mode:e.mode,xField:e.xField}:null}function vn(e,t,n){return t?o=>{var r;const i=Object.assign({},e(o));if(t.isActive)if(t.predicate(o))(null==n?void 0:n.selectedStyle)&&Object.assign(i,n.selectedStyle);else{const e=null!==(r=null==n?void 0:n.unselectedOpacity)&&void 0!==r?r:.2;i.opacity=e,i.fillOpacity=e,i.strokeOpacity=e,(null==n?void 0:n.unselectedStyle)&&Object.assign(i,n.unselectedStyle)}return i}:e}e.createContext(void 0);const xn="#007bff";function kn(e,t,n){const o=s(ln),i=function(){var e;const t=Ht(e=>e.theme),n=null===(e=null==t?void 0:t.colors)||void 0===e?void 0:e.categorical;return n&&n.length>0?n:void 0}();return r(()=>{var r;if(!t)return;const a=null!==(r=null!=n?n:i&&i.length>0?i:void 0)&&void 0!==r?r:"category10";if(0!==e.length){if("function"==typeof t){const n=Array.from(new Set(e.map(e=>t(e)+"")));if(o&&Object.keys(o).length>0){const e=an(n.map(e=>({_cat:e})),"_cat",a);return t=>o[t]||e(t)}return an(n.map(e=>({_cat:e})),"_cat",a)}if(o&&Object.keys(o).length>0){const n=an(e,t,a);return e=>o[e]||n(e)}return an(e,t,a)}if(o&&Object.keys(o).length>0){const e=an([{_:"a"}],"_",a);return t=>o[t]||e(t)}},[e,t,n,o,i])}function wn({selection:e,linkedHover:t,fallbackFields:i=[],unwrapData:a=!1,onObservation:s,chartType:c,chartId:u,onClick:p,hoverHighlight:h,colorByField:y}){const f=d(),g=bn(t,i),m=fn({name:(null==e?void 0:e.name)||"__unused__"}),b=gn({name:(null==g?void 0:g.name)||"hover",fields:(null==g?void 0:g.fields)||i||[]}),v=yn(e=>e.pushObservation),x=e?{isActive:m.isActive,predicate:m.predicate}:null,[k,w]=n(null),A=y||i[0],j=r(()=>{if(!h||null==k||!A)return null;const e=k,t=A;return{isActive:!0,predicate:n=>{var o;return("string"==typeof n[t]?n[t]:(null!==(o=n[t])&&void 0!==o?o:"")+"")===e}}},[h,k,A]),E=l(e=>{var n,o;if(t)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"x-position"===(null==g?void 0:g.mode)&&g.xField){const e=null==t?void 0:t[g.xField];null!=e&&Number.isFinite(Number(e))&&function(e,t,n){const o=Ne.positions.get(e);(null==o?void 0:o.locked)||o&&o.xValue===t&&o.sourceId===n||(Ne={positions:new Map(Ne.positions).set(e,{xValue:t,sourceId:n})},Te())}(g.name||"hover",Number(e),f)}"x-position"!==(null==g?void 0:g.mode)&&b.onHover(t)}else"x-position"===(null==g?void 0:g.mode)&&Re(g.name||"hover",f),"x-position"!==(null==g?void 0:g.mode)&&b.onHover(null);if(h&&A)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=null==t?void 0:t[A];w(null!=n?n+"":null)}else w(null);if(s||v){const t={timestamp:Date.now(),chartType:c||"unknown",chartId:u};if(e){let r=e.data||e.datum||e;Array.isArray(r)&&(r=r[0]);const i=Object.assign(Object.assign({},t),{type:"hover",datum:r||{},x:null!==(n=e.x)&&void 0!==n?n:0,y:null!==(o=e.y)&&void 0!==o?o:0});s&&s(i),v&&v(i)}else{const e=Object.assign(Object.assign({},t),{type:"hover-end"});s&&s(e),v&&v(e)}}},[t,b,g,f,s,c,u,v,h,A]),O=l(e=>{var t,n,o,r;if("x-position"===(null==g?void 0:g.mode)&&g.xField&&e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=null==t?void 0:t[g.xField];null!=n&&Number.isFinite(Number(n))&&function(e,t,n){const o=Ne.positions.get(e);if(null==o?void 0:o.locked){const t=new Map(Ne.positions);return t.delete(e),Ne={positions:t},Te(),!1}Ne={positions:new Map(Ne.positions).set(e,{xValue:t,sourceId:n,locked:!0})},Te()}(g.name||"hover",Number(n),f)}if(e&&p){let o=e.data||e.datum||e;Array.isArray(o)&&(o=o[0]),p(o,{x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0})}if(s||v){const t={timestamp:Date.now(),chartType:c||"unknown",chartId:u};if(e){let n=e.data||e.datum||e;Array.isArray(n)&&(n=n[0]);const i=Object.assign(Object.assign({},t),{type:"click",datum:n||{},x:null!==(o=e.x)&&void 0!==o?o:0,y:null!==(r=e.y)&&void 0!==r?r:0});s&&s(i),v&&v(i)}else{const e=Object.assign(Object.assign({},t),{type:"click-end"});s&&s(e),v&&v(e)}}},[p,s,v,c,u,g,f]);return o(()=>{if("x-position"!==(null==g?void 0:g.mode))return;const e=g.name||"hover";return()=>{We(e,f),Re(e,f)}},[null==g?void 0:g.mode,null==g?void 0:g.name,f]),{activeSelectionHook:x,hoverSelectionHook:j,customHoverBehavior:E,customClickBehavior:O,crosshairSourceId:f}}function An({data:e,colorBy:t,colorScale:n,showLegend:o,legendPosition:i="right",userMargin:a,defaults:l={top:50,bottom:60,left:70,right:40},categories:c}){const u=s(mn),d=void 0!==o?o:!u&&!!t,p=r(()=>{if(d&&t)return function({data:e,colorBy:t,colorScale:n,getColor:o,strokeColor:r,strokeWidth:i,categories:a}){return{legendGroups:[{styleFn:e=>{const t=e.color||"#333",n={fill:t,stroke:t};return void 0!==r&&(n.stroke=r),void 0!==i&&(n.strokeWidth=i),n},type:"fill",items:(a&&a.length>0?a:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t])))).map((r,i)=>{const a=e.find("function"==typeof t?e=>t(e)===r:e=>e[t]===r),s=a?o(a,t,n):n?n(r):nn[i%nn.length];return{label:r+"",color:s}}),label:""}]}}({data:e,colorBy:t,colorScale:n,getColor:rn,categories:c})},[d,t,e,n,c]),h=r(()=>{const e=Object.assign(Object.assign({},l),a);return p&&("right"===i&&110>e.right?e.right=110:"left"===i&&110>e.left?e.left=110:"top"===i&&50>e.top?e.top=50:"bottom"===i&&80>e.bottom&&(e.bottom=80)),e},[l,a,p,i]);return{legend:p,margin:h,legendPosition:i}}const jn={primary:{width:600,height:400,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:void 0,showLabels:void 0,marginDefaults:{top:50,bottom:60,left:70,right:40}},context:{width:400,height:250,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:10,bottom:10,left:10,right:10}},sparkline:{width:120,height:24,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:2,bottom:2,left:0,right:0}}};function En(e,t,n){var o,r,i,a,s,l,c;const u=jn[e||"primary"],d="context"===e||"sparkline"===e;return{width:null!==(o=t.width)&&void 0!==o?o:u.width,height:null!==(r=t.height)&&void 0!==r?r:u.height,showAxes:null!==(i=t.showAxes)&&void 0!==i?i:u.showAxes,showGrid:null!==(a=t.showGrid)&&void 0!==a?a:u.showGrid,enableHover:null!==(s=t.enableHover)&&void 0!==s?s:!!t.linkedHover||u.enableHover,showLegend:null!==(l=t.showLegend)&&void 0!==l?l:u.showLegend,showLabels:null!==(c=t.showLabels)&&void 0!==c?c:u.showLabels,title:d?void 0:t.title,description:t.description,summary:t.summary,accessibleTable:t.accessibleTable,xLabel:d?void 0:t.xLabel,yLabel:d?void 0:t.yLabel,categoryLabel:d?void 0:t.categoryLabel,valueLabel:d?void 0:t.valueLabel,marginDefaults:On(u.marginDefaults,t.showCategoryTicks,t.orientation)}}function On(e,t,n){if(!1!==t)return e;const o=Object.assign({},e);return"horizontal"===n?o.left=Math.min(o.left,15):o.bottom=Math.min(o.bottom,15),o}function Sn({componentName:t,message:n,diagnosticHint:o,width:r,height:i}){return e.createElement("div",{role:"alert",style:{width:r,height:Math.max(i,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"}},e.createElement("div",{style:{textAlign:"center",maxWidth:400}},e.createElement("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"}},t),e.createElement("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5}},n),o&&e.createElement("div",{"data-testid":"semiotic-diagnostic-hint",style:{marginTop:10,padding:"8px 12px",background:"rgba(128, 128, 128, 0.06)",borderRadius:4,fontSize:12,color:"rgba(128, 128, 128, 0.8)",fontFamily:"monospace",textAlign:"left",whiteSpace:"pre-wrap",lineHeight:1.6}},o)))}class Mn extends e.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){var n,o;null===(o=(n=this.props).onError)||void 0===o||o.call(n,e,t)}render(){if(this.state.error){const{fallback:t}=this.props,n=this.state.error;return"function"==typeof t?t(n):void 0!==t?t:e.createElement(Sn,{componentName:"ChartErrorBoundary",message:n.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}function Cn(e,t){const n=e.length,o=t.length,r=Array(o+1);for(let e=0;o>=e;e++)r[e]=e;for(let i=1;n>=i;i++){let n=r[0];r[0]=i;for(let a=1;o>=a;a++){const o=r[a];r[a]=e[i-1]===t[a-1]?n:1+Math.min(n,r[a],r[a-1]),n=o}}return r[o]}function $n(e,t,n=3){let o,r=n+1;for(const n of t){const t=Cn(e.toLowerCase(),n.toLowerCase());r>t&&(r=t,o=n)}return r>n?void 0:o}function zn(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}function Ln(e,t){var n;if(0===t.length)return null;const o=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(o)||o.includes(e.toLowerCase()))||(null!==(n=$n(e,t,3))&&void 0!==n?n:null)}const Pn={width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},frameProps:{type:"object"},onClick:{type:"function"}},Bn={xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"}},In={categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"},categoryFormat:{type:"function"}},Nn=["linear","monotoneX","monotoneY","step","stepAfter","stepBefore","basis","cardinal","catmullRom"],Dn=["vertical","horizontal"],Tn={LineChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Pn),Bn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},lineBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Nn},lineWidth:{type:"number"},showPoints:{type:"boolean"},pointRadius:{type:"number"},fillArea:{type:"boolean"},areaOpacity:{type:"number"}})},AreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Pn),Bn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Nn},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"}})},StackedAreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Pn),Bn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Nn},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"},normalize:{type:"boolean"}})},Scatterplot:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Pn),Bn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"}})},BubbleChart:{required:["data","sizeBy"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Pn),Bn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},bubbleOpacity:{type:"number"},bubbleStrokeWidth:{type:"number"},bubbleStrokeColor:{type:"string"}})},Heatmap:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Pn),Bn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},colorScheme:{type:"string",enum:["blues","reds","greens","viridis","custom"]},customColorScale:{type:["object","function"]},showValues:{type:"boolean"},valueFormat:{type:"function"},cellBorderColor:{type:"string"},cellBorderWidth:{type:"number"},showLegend:{type:"boolean"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}})},QuadrantChart:{required:["quadrants"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Pn),Bn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},quadrants:{type:"object"},xCenter:{type:"number"},yCenter:{type:"number"},centerlineStyle:{type:"object"},showQuadrantLabels:{type:"boolean"},quadrantLabelSize:{type:"number"},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"}})},MultiAxisLineChart:{required:["series"],dataShape:"array",dataAccessors:["xAccessor"],props:Object.assign(Object.assign(Object.assign({},Pn),Bn),{data:{type:"array"},xAccessor:{type:["string","function"]},series:{type:"array"},colorScheme:{type:["string","array"]},curve:{type:"string"},lineWidth:{type:"number"},annotations:{type:"array"}})},ConnectedScatterplot:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Pn),Bn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},orderAccessor:{type:["string","function"]},orderLabel:{type:"string"},pointRadius:{type:"number"},pointIdAccessor:{type:["string","function"]},annotations:{type:"array"}})},BarChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Pn),In),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Dn},sort:{type:["boolean","string","function"]},barPadding:{type:"number"}})},StackedBarChart:{required:["data","stackBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Pn),In),{data:{type:"array"},categoryAccessor:{type:["string","function"]},stackBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Dn},normalize:{type:"boolean"},barPadding:{type:"number"}})},LikertChart:{required:["levels"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor","levelAccessor","countAccessor"],props:Object.assign(Object.assign(Object.assign({},Pn),In),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},levelAccessor:{type:["string","function"]},countAccessor:{type:["string","function"]},levels:{type:"array"},orientation:{type:"string",enum:Dn},barPadding:{type:"number"}})},GroupedBarChart:{required:["data","groupBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Pn),In),{data:{type:"array"},categoryAccessor:{type:["string","function"]},groupBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Dn},barPadding:{type:"number"}})},SwarmPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Pn),In),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Dn},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},BoxPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Pn),In),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Dn},showOutliers:{type:"boolean"},outlierRadius:{type:"number"},categoryPadding:{type:"number"}})},Histogram:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Pn),In),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},bins:{type:"number"},relative:{type:"boolean"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},ViolinPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Pn),In),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Dn},bins:{type:"number"},curve:{type:"string"},showIQR:{type:"boolean"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},RidgelinePlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Pn),In),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},bins:{type:"number"},amplitude:{type:"number"},categoryPadding:{type:"number"}})},DotPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Pn),In),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Dn},sort:{type:["boolean","string","function"]},dotRadius:{type:"number"},categoryPadding:{type:"number"}})},PieChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},Pn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},startAngle:{type:"number"}})},DonutChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},Pn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},innerRadius:{type:"number"},centerContent:{type:["object","string","number"]},startAngle:{type:"number"}})},GaugeChart:{required:["value"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},Pn),{value:{type:"number"},min:{type:"number"},max:{type:"number"},thresholds:{type:"array"},arcWidth:{type:"number"},sweep:{type:"number"},showNeedle:{type:"boolean"},needleColor:{type:"string"},centerContent:{type:["object","string","number","function"]},valueFormat:{type:"function"},showScaleLabels:{type:"boolean"},backgroundColor:{type:"string"}})},FunnelChart:{required:["data"],dataShape:"array",dataAccessors:["stepAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Pn),In),{data:{type:"array"},stepAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},orientation:{type:"string",enum:["horizontal","vertical"]},connectorOpacity:{type:"number"},showCategoryTicks:{type:"boolean"},responsiveWidth:{type:"boolean"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}})},SwimlaneChart:{required:["subcategoryAccessor"],dataShape:"array",dataAccessors:["categoryAccessor","subcategoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Pn),In),{data:{type:"array"},categoryAccessor:{type:["string","function"]},subcategoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:["horizontal","vertical"]},barPadding:{type:"number"},showCategoryTicks:{type:"boolean"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]},responsiveWidth:{type:"boolean"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}})},ForceDirectedGraph:{required:["nodes","edges"],dataShape:"network",dataAccessors:["nodeIDAccessor","sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},Pn),{nodes:{type:"array"},edges:{type:"array"},nodeIDAccessor:{type:["string","function"]},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},nodeLabel:{type:["string","function"]},nodeSize:{type:["number","string","function"]},nodeSizeRange:{type:"array"},edgeWidth:{type:["number","string","function"]},edgeColor:{type:"string"},edgeOpacity:{type:"number"},iterations:{type:"number"},forceStrength:{type:"number"},showLabels:{type:"boolean"}})},SankeyDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},Pn),{nodes:{type:"array"},edges:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target","gradient"]},orientation:{type:"string",enum:Dn},nodeAlign:{type:"string",enum:["justify","left","right","center"]},nodePaddingRatio:{type:"number"},nodeWidth:{type:"number"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"},edgeSort:{type:"function"}})},ChordDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},Pn),{nodes:{type:"array"},edges:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target"]},padAngle:{type:"number"},groupWidth:{type:"number"},sortGroups:{type:"function"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"}})},TreeDiagram:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},Pn),{data:{type:"object"},layout:{type:"string",enum:["tree","cluster","partition","treemap","circlepack"]},orientation:{type:"string",enum:["vertical","horizontal","radial"]},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},edgeStyle:{type:"string",enum:["line","curve"]},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},nodeSize:{type:"number"}})},Treemap:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},Pn),{data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]}})},CirclePack:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},Pn),{data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]},circleOpacity:{type:"number"}})},OrbitDiagram:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},Pn),{data:{type:"object"},childrenAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},orbitMode:{type:["string","array"]},speed:{type:"number"},revolution:{type:"function"},eccentricity:{type:["number","function"]},orbitSize:{type:["number","function"]},nodeRadius:{type:["number","function"]},showRings:{type:"boolean"},showLabels:{type:"boolean"},animated:{type:"boolean"},colorByDepth:{type:"boolean"},annotations:{type:"array"},foregroundGraphics:{type:"object"}})},RealtimeLineChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},stroke:{type:"string"},strokeWidth:{type:"number"},strokeDasharray:{type:"string"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeHistogram:{required:["binSize"],dataShape:"realtime",dataAccessors:[],props:{binSize:{type:"number"},size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},fill:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},gap:{type:"number"},brush:{type:["boolean","string","object"]},onBrush:{type:"function"},linkedBrush:{type:["string","object"]},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeSwarmChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},radius:{type:"number"},fill:{type:"string"},opacity:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeWaterfallChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},positiveColor:{type:"string"},negativeColor:{type:"string"},connectorStroke:{type:"string"},connectorWidth:{type:"number"},gap:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeHeatmap:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},heatmapXBins:{type:"number"},heatmapYBins:{type:"number"},aggregation:{type:"string",enum:["count","sum","mean"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"}}}};function Rn(e,t){return(Array.isArray(t)?t:[t]).includes(Array.isArray(e)?"array":typeof e)}const Wn=new Set(["TreeDiagram","Treemap","CirclePack","OrbitDiagram"]),_n=new Set(["ForceDirectedGraph","SankeyDiagram","ChordDiagram"]),Fn=new Set(["BarChart","StackedBarChart","GroupedBarChart","AreaChart","StackedAreaChart"]),Hn=new Set(["LineChart","AreaChart","StackedAreaChart"]),qn=new Set(["BarChart","StackedBarChart","GroupedBarChart","FunnelChart"]);function Gn(e){const t=e.match(/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i);if(!t)return null;const[n,o,r]=[parseInt(t[1],16)/255,parseInt(t[2],16)/255,parseInt(t[3],16)/255],i=e=>e>.03928?Math.pow((e+.055)/1.055,2.4):e/12.92;return.2126*i(n)+.7152*i(o)+.0722*i(r)}function Vn(e,t){const n=Gn(e),o=Gn(t);return null===n||null===o?null:(Math.max(n,o)+.05)/(Math.min(n,o)+.05)}const Un=["xAccessor","yAccessor","timeAccessor","valueAccessor","categoryAccessor","colorBy","sizeBy","lineBy","areaBy","stackBy","groupBy","orderAccessor","y0Accessor","sourceAccessor","targetAccessor","nodeIDAccessor","childrenAccessor","costAccessor"];function Zn(e,t){const n=[],o=function(e,t){const n=[],o=Tn[e];if(!o)return{valid:!1,errors:[`Unknown component "${e}". Valid components: ${Object.keys(Tn).join(", ")}`]};for(const r of o.required)null==t[r]&&n.push(`"${r}" is required for ${e}.`);for(const[e,r]of Object.entries(t)){if(null==r)continue;const t=o.props[e];if(t){if(!Rn(r,t.type)){const o=Array.isArray(t.type)?t.type.join(" | "):t.type;n.push(`"${e}" should be ${o}, got ${Array.isArray(r)?"array":typeof r}.`);continue}t.enum&&"string"==typeof r&&!t.enum.includes(r)&&n.push(`"${e}" value "${r}" is not valid. Expected one of: ${t.enum.join(", ")}.`)}}const r=Object.keys(o.props),i=new Set(r);for(const o of Object.keys(t))if(void 0!==t[o]&&!i.has(o)){const t=$n(o,r),i=t?`Unknown prop "${o}" for ${e}. Did you mean "${t}"?`:`Unknown prop "${o}" for ${e}. Valid props: ${r.join(", ")}.`;n.push(i)}if("array"===o.dataShape){const r=t.data,i={};for(const e of o.dataAccessors){const n=t[e];"string"==typeof n&&(i[e]=n)}const a=function({componentName:e,data:t,accessors:n,requiredProps:o}){if(o)for(const[t,n]of Object.entries(o))if(null==n)return`${e}: ${t} is required. Provide a field name or function.`;if(null==t)return null;if(!Array.isArray(t)||0===t.length)return e+": No data provided. Pass a non-empty array to the data prop.";if(!Array.isArray(t)&&"object"==typeof t)return e+": data should be an array, but received an object. If this is hierarchical data, use TreeDiagram, Treemap, or CirclePack instead.";if(n){const o=zn(t).find(e=>e&&"object"==typeof e);if(o){const t=Object.keys(o);for(const[r,i]of Object.entries(n))if(i&&"string"==typeof i&&!(i in o)){const n=Ln(i,t),o=n?` Try ${r}="${n}".`:"";return`${e}: ${r} "${i}" not found in data. Available fields: ${t.join(", ")}.${o}`}}}return null}({componentName:e,data:r,accessors:Object.keys(i).length>0?i:void 0});a&&n.push(a)}else if("object"===o.dataShape){const o=function({componentName:e,data:t,dataLabel:n="data"}){return null==t?`${e}: No ${n} provided. Pass a hierarchical object with children: { name: "root", children: [...] }.`:Array.isArray(t)?`${e}: ${n} should be a single root object, not an array. Expected: { name: "root", children: [...] }. If you have flat data, use LineChart, BarChart, or Scatterplot instead.`:null}({componentName:e,data:t.data});o&&n.push(o)}else if("network"===o.dataShape){const r=function({componentName:e,nodes:t,edges:n,nodesRequired:o=!1,edgesRequired:r=!0,accessors:i}){if(null==t&&null==n)return null;if(r&&(!n||!Array.isArray(n)||0===n.length))return e+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(o&&(!t||!Array.isArray(t)||0===t.length))return e+': No nodes provided. Pass a non-empty array: nodes={[{ id: "A" }, { id: "B" }, ...]}.';if(i&&t&&t.length>0){const n=zn(t).find(e=>e&&"object"==typeof e);if(n){const t=Object.keys(n);for(const[o,r]of Object.entries(i))if(r&&"string"==typeof r&&!(r in n)){const n=Ln(r,t),i=n?` Try ${o}="${n}".`:"";return`${e}: ${o} "${r}" not found in node data. Available fields: ${t.join(", ")}.${i}`}}}return null}({componentName:e,nodes:t.nodes,edges:t.edges,nodesRequired:o.required.includes("nodes"),edgesRequired:o.required.includes("edges")});r&&n.push(r)}return{valid:0===n.length,errors:n}}(e,t);for(const e of o.errors)n.push({severity:"error",code:"VALIDATION",message:e,fix:""});return Tn[e]?(function(e,t,n){const o=Tn[e];if(o){if("array"===o.dataShape){const e=t.data;e&&Array.isArray(e)&&0===e.length&&n.push({severity:"error",code:"EMPTY_DATA",message:"data is an empty array — chart will render blank.",fix:"Provide at least one data point: data={[{ x: 1, y: 2 }]}."})}"network"===o.dataShape&&t.edges&&Array.isArray(t.edges)&&0===t.edges.length&&n.push({severity:"error",code:"EMPTY_EDGES",message:"edges is an empty array — network chart will render blank.",fix:'Provide at least one edge: edges={[{ source: "A", target: "B" }]}.'})}}(e,t,n),function(e,t,n){const o=t.width,r=t.height;if(void 0===o||"number"==typeof o&&o>0||n.push({severity:"error",code:"BAD_WIDTH",message:`width=${JSON.stringify(o)} — chart needs a positive number.`,fix:"Set width={600} or use responsiveWidth={true}."}),void 0===r||"number"==typeof r&&r>0||n.push({severity:"error",code:"BAD_HEIGHT",message:`height=${JSON.stringify(r)} — chart needs a positive number.`,fix:"Set height={400} or use responsiveHeight={true}."}),t.size&&Array.isArray(t.size)){const[e,o]=t.size;(null!=e&&0>=e||null!=o&&0>=o)&&n.push({severity:"error",code:"BAD_SIZE",message:`size=[${e}, ${o}] — both dimensions must be positive.`,fix:"Set size={[600, 400]}."})}}(0,t,n),function(e,t,n){const o=Tn[e];if(!o||"array"!==o.dataShape)return;const r=t.data;if(!r||!Array.isArray(r)||0===r.length)return;const i=r[0];if(!i||"object"!=typeof i)return;const a=Object.keys(i);for(const e of o.dataAccessors){const o=t[e];"string"==typeof o&&(o in i||n.push({severity:"error",code:"ACCESSOR_MISSING",message:`${e}="${o}" not found in data. Available fields: ${a.join(", ")}.`,fix:`Change ${e} to one of: ${a.map(e=>`"${e}"`).join(", ")}.`}))}}(e,t,n),function(e,t,n){Wn.has(e)&&Array.isArray(t.data)&&n.push({severity:"error",code:"HIERARCHY_FLAT_ARRAY",message:e+" expects hierarchical data but received a flat array.",fix:'Pass a root object: data={{ name: "root", children: [...] }}. For flat data, use BarChart or LineChart.'})}(e,t,n),function(e,t,n){_n.has(e)&&(t.edges||t.data||n.push({severity:"error",code:"NETWORK_NO_EDGES",message:e+" requires an edges prop.",fix:'Provide edges={[{ source: "A", target: "B", value: 10 }]}.'}))}(e,t,n),function(e,t,n){const o=Tn[e];if(!o||"array"!==o.dataShape)return;const r=t.data;if(!r||!Array.isArray(r)||0===r.length)return;const i=r[0];if(!i||"object"!=typeof i)return;const a=t.xAccessor;"string"==typeof a&&i[a]instanceof Date&&!t.xFormat&&n.push({severity:"warning",code:"DATE_NO_FORMAT",message:`xAccessor "${a}" contains Date objects but no xFormat is provided. Axis ticks may display "[object Object]".`,fix:"Add xFormat={d => d.toLocaleDateString()} or use timestamps (d.getTime()) instead of Date objects."})}(e,t,n),function(e,t,n){t.linkedHover&&!t.selection&&n.push({severity:"warning",code:"LINKED_HOVER_NO_SELECTION",message:"linkedHover is set but selection is not — this chart emits hover events but won't highlight from others.",fix:`Add selection={{ name: "${"object"==typeof t.linkedHover&&t.linkedHover.name||"hl"}" }} to receive cross-highlights.`})}(0,t,n),function(e,t,n){var o;if(!Fn.has(e))return;const r=t.rExtent||t.yExtent;r&&Array.isArray(r)&&r.length>=1&&null!=r[0]&&0!==r[0]&&n.push({severity:"warning",code:"NON_ZERO_BASELINE",message:`${e} has a non-zero baseline (${r[0]}). Bar and area charts should start at zero to avoid exaggerating differences.`,fix:`Remove the custom extent minimum or set it to 0: rExtent={[0, ${null!==(o=r[1])&&void 0!==o?o:"auto"}]}. For trend-focused charts, use LineChart instead.`})}(e,t,n),function(e,t,n){if(!Hn.has(e))return;if(t.gapStrategy)return;const o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;const r=t.yAccessor||"y";"string"==typeof r&&o.some(e=>{const t=e[r];return null==t||Number.isNaN(t)})&&n.push({severity:"warning",code:"DATA_GAPS",message:`Data contains null/undefined/NaN values in "${r}". Default behavior breaks the line at gaps.`,fix:'Set gapStrategy="break" (default), "interpolate", or "zero" to control gap handling.'})}(e,t,n),function(e,t,n){var o,r;const i=null!==(o=t.width)&&void 0!==o?o:600,a=null!==(r=t.height)&&void 0!==r?r:400,s=t.margin;if(!s||"object"!=typeof s)return;const l=(s.left||0)+(s.right||0),c=(s.top||0)+(s.bottom||0);i>l||n.push({severity:"error",code:"MARGIN_OVERFLOW_H",message:`Horizontal margins (${l}px) >= width (${i}px) — no drawing area left.`,fix:"Reduce margin.left/right or increase width."}),a>c||n.push({severity:"error",code:"MARGIN_OVERFLOW_V",message:`Vertical margins (${c}px) >= height (${a}px) — no drawing area left.`,fix:"Reduce margin.top/bottom or increase height."})}(0,t,n),function(e,t,n){var o;const r=Tn[e];if(!r||"array"!==r.dataShape)return;const i=t.data;if(!i||!Array.isArray(i)||0===i.length)return;const a=[];t.xAccessor&&"string"==typeof t.xAccessor&&a.push({prop:"xAccessor",name:t.xAccessor}),t.yAccessor&&"string"==typeof t.yAccessor&&a.push({prop:"yAccessor",name:t.yAccessor}),t.valueAccessor&&"string"==typeof t.valueAccessor&&a.push({prop:"valueAccessor",name:t.valueAccessor});const s=Math.min(i.length,5);for(const e of a){let t=!0;for(let n=0;s>n;n++){const r=null===(o=i[n])||void 0===o?void 0:o[e.name];if("number"==typeof r&&Number.isFinite(r)){t=!1;break}}t&&n.push({severity:"error",code:"DEGENERATE_EXTENT",message:`${e.prop}="${e.name}" produces NaN or non-finite values for all sampled data points — chart extents will be invalid.`,fix:`Ensure data[].${e.name} contains finite numbers, or use a function accessor to transform values.`})}}(e,t,n),function(e,t,n){if(!qn.has(e))return;const o=t.barPadding;"number"==typeof o&&10>o&&n.push({severity:"warning",code:"BAR_PADDING_INVISIBLE",message:`barPadding=${o} is very small — bars may appear to have no spacing between them.`,fix:"Increase barPadding to at least 10 for visible gaps, e.g. barPadding={12}."})}(e,t,n),function(e,t,n){if("bottom"!==t.legendPosition)return;const o=t.margin;if(!o||"object"!=typeof o)return;const r=o.bottom;"number"==typeof r&&70>r&&n.push({severity:"warning",code:"BOTTOM_MARGIN_WITH_LEGEND",message:`legendPosition="bottom" with margin.bottom=${r}px — legend may overlap axis labels.`,fix:"Increase margin.bottom to at least 70, e.g. margin={{ ...margin, bottom: 80 }}."})}(0,t,n),function(e,t,n){var o;if(!t.showLegend)return;if("right"!==(null!==(o=t.legendPosition)&&void 0!==o?o:"right"))return;const r=t.margin;if(!r||"object"!=typeof r)return;const i=r.right;"number"==typeof i&&100>i&&n.push({severity:"warning",code:"LEGEND_MARGIN_TIGHT",message:`showLegend is true with legendPosition="right" but margin.right=${i}px — legend may be clipped or overlap the chart.`,fix:"Increase margin.right to at least 100, e.g. margin={{ ...margin, right: 120 }}."})}(0,t,n),function(e,t,n){if("Heatmap"!==e)return;const o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;const r=o[0];if(r&&"object"==typeof r)for(const e of["xAccessor","yAccessor"]){const o=t[e];if("string"!=typeof o)continue;const i=r[o];"string"==typeof i&&n.push({severity:"warning",code:"HEATMAP_STRING_ACCESSOR",message:`${e}="${o}" resolves to string values (e.g. "${i}"). Heatmap will use categorical axis handling which may produce unexpected cell layout.`,fix:"If you intend categorical axes this is fine. Otherwise, convert values to numbers before passing data."})}}(e,t,n),function(e,t,n){const o=t.colorScheme;if(!o||!Array.isArray(o))return;const r="string"==typeof t.background?t.background:"#ffffff";if(!r.startsWith("#"))return;const i=[];for(const e of o){if("string"!=typeof e||!e.startsWith("#"))continue;const t=Vn(e,r);null!==t&&3>t&&i.push(`${e} (${t.toFixed(1)}:1)`)}i.length>0&&n.push({severity:"warning",code:"LOW_COLOR_CONTRAST",message:`${i.length} color(s) in colorScheme have < 3:1 contrast against background "${r}": ${i.join(", ")}. Data marks may be hard to see.`,fix:'Use darker colors on light backgrounds or lighter colors on dark backgrounds. Import COLOR_BLIND_SAFE_CATEGORICAL from "semiotic" for an accessible preset.'})}(0,t,n),function(e,t,n){const o=t.colorScheme;if(!o||!Array.isArray(o)||2>o.length)return;const r=o.filter(e=>"string"==typeof e&&e.startsWith("#"));if(2>r.length)return;const i=[];for(let e=0;r.length-1>e;e++){const t=Vn(r[e],r[e+1]);null!==t&&1.5>t&&i.push(`${r[e]} / ${r[e+1]} (${t.toFixed(1)}:1)`)}i.length>0&&n.push({severity:"warning",code:"LOW_ADJACENT_CONTRAST",message:`${i.length} adjacent color pair(s) in colorScheme have very similar luminance: ${i.join("; ")}. Categories may be hard to distinguish.`,fix:'Alternate light and dark colors in the scheme, or use COLOR_BLIND_SAFE_CATEGORICAL from "semiotic" for a pre-tested palette.'})}(0,t,n),function(e,t,n){const o="string"==typeof t.title&&t.title.trim().length>0,r="string"==typeof t.description&&t.description.trim().length>0,i="string"==typeof t.summary&&t.summary.trim().length>0;o||r||i||n.push({severity:"warning",code:"MISSING_DESCRIPTION",message:'No title, description, or summary provided. Screen readers will use a generic label like "XY chart".',fix:'Add a title="..." prop for a brief label, or description="..." for a detailed aria-label, or summary="..." for a screen-reader-only note describing the chart\'s purpose.'})}(0,t,n),function(e,t,n){const o=[];for(const e of Un)"function"==typeof t[e]&&o.push(e);o.length>0&&n.push({severity:"warning",code:"FUNCTION_ACCESSOR",message:`Function accessor${o.length>1?"s":""} detected: ${o.join(", ")}. If defined inline (e.g. \`xAccessor={d => d.value}\`), every parent re-render creates a new reference which may trigger unnecessary scene rebuilds.`,fix:'Use string accessors when possible (e.g. xAccessor="value"), or memoize with useCallback / define outside the component.'})}(0,t,n),{ok:n.every(e=>"warning"===e.severity),diagnoses:n}):{ok:0===n.length,diagnoses:n}}var Yn;const Xn="undefined"!=typeof process&&"production"!==(null===(Yn=process.env)||void 0===Yn?void 0:Yn.NODE_ENV);function Kn({componentName:t,width:n,height:o,chartProps:r,children:i}){return e.createElement(Mn,{fallback:i=>{let a="";if(Xn&&r)try{const e=Zn(t,r);e.ok||(a=e.diagnoses.map(e=>`${"error"===e.severity?"✗":"⚠"} ${e.message}${e.fix?" — Fix: "+e.fix:""}`).join("\n"))}catch(e){}return e.createElement(Sn,{componentName:t,message:i.message,diagnosticHint:a,width:n,height:o})}},i)}const Jn={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #999)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},Qn={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function eo(t,n,o,r){return!1===r||null==t||Array.isArray(t)&&t.length>0?null:Array.isArray(t)?e.createElement("div",{style:Object.assign(Object.assign({},Jn),{width:n,height:o})},r||"No data available"):null}function to(t,n,o){if(!t)return null;const r=Math.min(5,Math.floor(o/40)),i=Math.max(8,Math.floor(o/(3*r))),a=Math.max(6,Math.floor(o/(2.5*r))),s=Math.floor((o-(r*(i+a)-a))/2);return e.createElement("div",{style:{width:n,height:o,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"}},Array.from({length:r},(t,o)=>e.createElement("div",{key:o,className:"semiotic-loading-bar",style:Object.assign(Object.assign({},Qn),{position:"absolute",top:s+o*(i+a),left:Math.floor(.1*n),width:30+(37*o+13)%50+"%",height:i,opacity:.5+o%2*.2})})))}function no(e,t,n,o){if(!Xn)return;if(!t||0===t.length)return;if("string"!=typeof o)return;const r=t[0];if(!r||"object"!=typeof r)return;if(o in r)return;const i=Object.keys(r).join(", ");console.warn(`[semiotic] ${e}: ${n} "${o}" not found in data. Available keys: ${i}`)}function oo(e,t,n,o){return new(n||(n=Promise))(function(r,i){function a(e){try{l(o.next(e))}catch(e){i(e)}}function s(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}l((o=o.apply(e,t||[])).next())})}function ro(e){return e}function io(e,t){var n=t.id,o=t.bbox,r=null==t.properties?{}:t.properties,i=function(e,t){var n=function(e){if(null==e)return ro;var t,n,o=e.scale[0],r=e.scale[1],i=e.translate[0],a=e.translate[1];return function(e,s){s||(t=n=0);var l=2,c=e.length,u=Array(c);for(u[0]=(t+=e[0])*o+i,u[1]=(n+=e[1])*r+a;c>l;)u[l]=e[l],++l;return u}}(e.transform),o=e.arcs;function r(e,t){t.length&&t.pop();for(var r=o[0>e?~e:e],i=0,a=r.length;a>i;++i)t.push(n(r[i],i));0>e&&function(e,t){for(var n,o=e.length,r=o-t;r<--o;)n=e[r],e[r++]=e[o],e[o]=n}(t,a)}function i(e){return n(e)}function a(e){for(var t=[],n=0,o=e.length;o>n;++n)r(e[n],t);return 2>t.length&&t.push(t[0]),t}function s(e){for(var t=a(e);4>t.length;)t.push(t[0]);return t}function l(e){return e.map(s)}return function e(t){var n,o=t.type;switch(o){case"GeometryCollection":return{type:o,geometries:t.geometries.map(e)};case"Point":n=i(t.coordinates);break;case"MultiPoint":n=t.coordinates.map(i);break;case"LineString":n=a(t.arcs);break;case"MultiLineString":n=t.arcs.map(a);break;case"Polygon":n=l(t.arcs);break;case"MultiPolygon":n=t.arcs.map(l);break;default:return null}return{type:o,coordinates:n}}(t)}(e,t);return null==n&&null==o?{type:"Feature",properties:r,geometry:i}:null==o?{type:"Feature",id:n,properties:r,geometry:i}:{type:"Feature",id:n,bbox:o,properties:r,geometry:i}}"function"==typeof SuppressedError&&SuppressedError;const ao=new Map;function so(e){var t;return null!==(t=e.default)&&void 0!==t?t:e}function lo(e){return oo(this,void 0,void 0,function*(){const t=ao.get(e);if(t)return t;const{topology:n,objectName:o}=yield function(e){return oo(this,void 0,void 0,function*(){switch(e){case"world-110m":return{topology:so(yield import("world-atlas/countries-110m.json")),objectName:"countries"};case"world-50m":return{topology:so(yield import("world-atlas/countries-50m.json")),objectName:"countries"};case"land-110m":return{topology:so(yield import("world-atlas/land-110m.json")),objectName:"land"};case"land-50m":return{topology:so(yield import("world-atlas/land-50m.json")),objectName:"land"};default:throw Error(`Unknown reference geography: "${e}". Supported: "world-110m", "world-50m", "land-110m", "land-50m".`)}})}(e);if(!n||!n.objects)throw Error(`resolveReferenceGeography("${e}"): Failed to load topology. Got ${typeof n} with keys: ${n?Object.keys(n).join(", "):"none"}`);const r=function(e,t){return"string"==typeof t&&(t=e.objects[t]),"GeometryCollection"===t.type?{type:"FeatureCollection",features:t.geometries.map(function(t){return io(e,t)})}:io(e,t)}(n,n.objects[o]),i="features"in r?r.features:[r];return ao.set(e,i),i})}function co(e){const t=r(()=>Array.isArray(e)?e:void 0,[e]),[i,a]=n(null);return o(()=>{if(e&&!Array.isArray(e)){if("string"==typeof(t=e)&&["world-110m","world-50m","land-110m","land-50m"].includes(t)){let t=!1;return a(null),lo(e).then(e=>{t||a(e)}),()=>{t=!0}}var t;"production"!==process.env.NODE_ENV&&console.warn(`[semiotic] Unknown areas reference: "${e}". Supported: "world-110m", "world-50m", "land-110m", "land-50m".`),a(null)}else a(null)},[e]),void 0!==t?t:i}const uo={blues:K,reds:X,greens:Y,viridis:V};function po(t){const n=En(t.mode,{width:t.width,height:t.height,showLegend:t.showLegend,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary}),{areas:o,valueAccessor:i,colorScheme:a="blues",projection:s="equalEarth",graticule:l,fitPadding:c,zoomable:u,zoomExtent:d,onZoom:p,dragRotate:h,tileURL:y,tileAttribution:f,tileCacheSize:g,tooltip:m,areaOpacity:b=1,annotations:v,margin:x,className:k,selection:w,linkedHover:A,onObservation:E,onClick:S,chartId:M,loading:C,emptyContent:$,frameProps:z={}}=t,L=null!=u?u:!!y,P=co(o),B=r(()=>"function"==typeof i?i:e=>{var t,n;return null!==(n=null===(t=null==e?void 0:e.properties)||void 0===t?void 0:t[i])&&void 0!==n?n:null==e?void 0:e[i]},[i]),I=r(()=>{if(!P)return j(K).domain([0,1]);const e=P.map(e=>B(e)).filter(e=>null!=e&&isFinite(e)),[t,n]=O(e);return j(uo[a]||K).domain([null!=t?t:0,null!=n?n:1])},[P,B,a]),{activeSelectionHook:N,customHoverBehavior:D,customClickBehavior:T}=wn({selection:w,linkedHover:A,onObservation:E,onClick:S,chartType:"ChoroplethMap",chartId:M}),R=r(()=>{const e=e=>{const t=B(e);return{fill:null!=t&&isFinite(t)?I(t):"#ccc",stroke:"#999",strokeWidth:.5,fillOpacity:b}};return N?vn(e,N,w):e},[B,I,N,w,b]),W=r(()=>t=>{var n,o;const r=(null===(n=null==t?void 0:t.properties)||void 0===n?void 0:n.name)||(null===(o=null==t?void 0:t.properties)||void 0===o?void 0:o.NAME)||(null==t?void 0:t.name)||(null==t?void 0:t.NAME)||"Feature",i=B(t);return e.createElement("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12}},e.createElement("div",{style:{fontWeight:600}},r),null!=i&&e.createElement("div",{style:{opacity:.7}},"number"==typeof(a=i)&&isFinite(a)?Number.isInteger(a)?a.toLocaleString():a.toLocaleString(void 0,{maximumFractionDigits:2}):(null!=a?a:"")+""));var a},[B]),_=r(()=>Object.assign({top:10,right:10,bottom:10,left:10},x),[x]),F=to(C,n.width,n.height)||(P?null:to(!0,n.width,n.height)),H=F?null:eo(P,n.width,n.height,$);if(Array.isArray(P)&&P.length>0){const t=P[0];if(!t||"object"!=typeof t||!t.geometry)return e.createElement(Sn,{componentName:"ChoroplethMap",message:"ChoroplethMap: areas must be an array of GeoJSON Features with a geometry property.",width:n.width,height:n.height})}const q=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({projection:s,areas:P,areaStyle:R,size:[n.width,n.height],margin:_,enableHover:!0,tooltipContent:!1===m?()=>null:!0===m?W:Qt(m)||W},null!=l&&{graticule:l}),null!=c&&{fitPadding:c}),L&&{zoomable:!0}),d&&{zoomExtent:d}),p&&{onZoom:p}),null!=h&&{dragRotate:h}),y&&{tileURL:y}),f&&{tileAttribution:f}),g&&{tileCacheSize:g}),(A||E||S)&&{customHoverBehavior:D}),(E||S)&&{customClickBehavior:T}),v&&v.length>0&&{annotations:v}),n.title&&{title:n.title}),n.description&&{description:n.description}),n.summary&&{summary:n.summary}),void 0!==n.accessibleTable&&{accessibleTable:n.accessibleTable}),k&&{className:k}),z);return F||H||e.createElement(Kn,{componentName:"ChoroplethMap",width:n.width,height:n.height},e.createElement(Zt,Object.assign({},q)))}po.displayName="ChoroplethMap";const ho=c(function(o,i){const a=t(null);u(i,()=>({push:e=>{var t;return null===(t=a.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=a.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=a.current)||void 0===t?void 0:t.removePoint(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o,r;const i=null!==(o=null===(n=a.current)||void 0===n?void 0:n.removePoint(e))&&void 0!==o?o:[];for(const e of i)null===(r=a.current)||void 0===r||r.push(t(e));return i},clear:()=>{var e;return null===(e=a.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=a.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const s=En(o.mode,{width:o.width,height:o.height,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary}),{points:c,xAccessor:d="lon",yAccessor:p="lat",sizeBy:h,sizeRange:y=[3,30],colorBy:f,colorScheme:g,projection:m="equalEarth",graticule:b,fitPadding:v,zoomable:x,zoomExtent:k,onZoom:w,dragRotate:A,tileURL:j,tileAttribution:E,tileCacheSize:O,areas:S,areaStyle:M={fill:"#f0f0f0",stroke:"#ccc",strokeWidth:.5},tooltip:C,annotations:$,margin:z,className:L,selection:P,linkedHover:B,onObservation:I,onClick:N,chartId:D,loading:T,emptyContent:R,legendInteraction:W,legendPosition:_,frameProps:F={}}=o,H=null!=x?x:!!j,q=co(S),G=c||[],{activeSelectionHook:V,customHoverBehavior:U,customClickBehavior:Z}=wn({selection:P,linkedHover:B,fallbackFields:f?["string"==typeof f?f:""]:[],onObservation:I,onClick:N,chartType:"ProportionalSymbolMap",chartId:D}),Y=kn(G,f,g),X=r(()=>{if(!h)return;const e="function"==typeof h?h:e=>null==e?void 0:e[h],t=G.filter(Boolean).map(t=>e(t)).filter(e=>null!=e&&isFinite(e));return 0!==t.length?[Math.min(...t),Math.max(...t)]:void 0},[G,h]),K=r(()=>{const e=e=>({fill:f?rn(e,f,Y):xn,fillOpacity:.7,stroke:"#fff",strokeWidth:.5,r:h?sn(e,h,y,X):6});return V?vn(e,V,P):e},[f,Y,h,y,X,V,P]),J=r(()=>{if(!f)return[];const e="function"==typeof f?f:e=>e[f],t=new Set;for(const n of G){const o=e(n);null!=o&&t.add(o+"")}return Array.from(t)},[G,f]),Q=function(e,t,o){const[i,a]=n(null),[s,c]=n(new Set),u=l(t=>{"highlight"===e&&a(t?t.label:null)},[e]),d=l(t=>{"isolate"===e&&c(e=>{const n=new Set(e);return n.has(t.label)?n.delete(t.label):n.add(t.label),n.size===o.length?new Set:n})},[e,o.length]),p=r(()=>{if(!e||"none"===e||!t)return null;const n="string"==typeof t?t:null;return"highlight"===e&&null!=i?{isActive:!0,predicate:e=>(n?e[n]:"function"==typeof t?t(e):null)===i}:"isolate"===e&&s.size>0?{isActive:!0,predicate:e=>{const o=n?e[n]:"function"==typeof t?t(e):null;return s.has(o)}}:null},[e,t,i,s]);return{highlightedCategory:"highlight"===e?i:null,isolatedCategories:"isolate"===e?s:new Set,onLegendHover:u,onLegendClick:d,legendSelectionHook:p}}(W,f,J),{legend:ee,margin:te,legendPosition:ne}=An({data:G,colorBy:f,colorScale:Y,showLegend:s.showLegend,legendPosition:_,userMargin:z,defaults:{top:10,bottom:10,left:10,right:10}}),oe=r(()=>t=>{const n=(null==t?void 0:t.name)||(null==t?void 0:t.label)||(null==t?void 0:t.NAME)||(null==t?void 0:t.id),o="string"==typeof h?h:null,r=("function"==typeof h?h:e=>e[h])(t),i=e=>"number"==typeof e&&isFinite(e)?Number.isInteger(e)?e.toLocaleString():e.toLocaleString(void 0,{maximumFractionDigits:2}):(null!=e?e:"")+"",a="string"==typeof f?f:null,s=a?null==t?void 0:t[a]:null;return e.createElement("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12}},n&&e.createElement("div",{style:{fontWeight:600,marginBottom:2}},n),o&&null!=r&&e.createElement("div",null,e.createElement("span",{style:{opacity:.7}},o,": "),i(r)),a&&null!=s&&e.createElement("div",null,e.createElement("span",{style:{opacity:.7}},a,": "),s+""),!n&&!o&&Object.entries(t).filter(([e])=>"data"!==e&&"x"!==e&&"y"!==e&&"time"!==e).slice(0,4).map(([t,n])=>e.createElement("div",{key:t},e.createElement("span",{style:{opacity:.7}},t,": "),i(n))))},[h,f]),re=to(T,s.width,s.height),ie=re?null:eo(c,s.width,s.height,R);no("ProportionalSymbolMap",G,"xAccessor",d),no("ProportionalSymbolMap",G,"yAccessor",p);const ae=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({projection:m},null!=c&&{points:G}),{xAccessor:d,yAccessor:p,pointStyle:K}),o.pointIdAccessor&&{pointIdAccessor:o.pointIdAccessor}),q&&{areas:q,areaStyle:M}),null!=b&&{graticule:b}),null!=v&&{fitPadding:v}),H&&{zoomable:!0}),k&&{zoomExtent:k}),w&&{onZoom:w}),null!=A&&{dragRotate:A}),j&&{tileURL:j}),E&&{tileAttribution:E}),O&&{tileCacheSize:O}),{size:[s.width,s.height],margin:te,enableHover:!0,tooltipContent:!1===C?()=>null:Qt(C)||oe}),ee&&{legend:ee,legendPosition:ne}),W&&"none"!==W&&{legendHoverBehavior:Q.onLegendHover,legendClickBehavior:Q.onLegendClick,legendHighlightedCategory:Q.highlightedCategory,legendIsolatedCategories:Q.isolatedCategories}),(B||I||N)&&{customHoverBehavior:U}),(I||N)&&{customClickBehavior:Z}),$&&$.length>0&&{annotations:$}),s.title&&{title:s.title}),s.description&&{description:s.description}),s.summary&&{summary:s.summary}),void 0!==s.accessibleTable&&{accessibleTable:s.accessibleTable}),L&&{className:L}),F);return re||ie||e.createElement(Kn,{componentName:"ProportionalSymbolMap",width:s.width,height:s.height},e.createElement(Zt,Object.assign({ref:a},ae)))});function yo(t){const n=En(t.mode,{width:t.width,height:t.height,showLegend:t.showLegend,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary}),{flows:o,nodes:i,nodeIdAccessor:a="id",xAccessor:s="lon",yAccessor:c="lat",valueAccessor:u="value",projection:d="equalEarth",graticule:p,fitPadding:h,zoomable:y,zoomExtent:f,onZoom:g,dragRotate:m,tileURL:b,tileAttribution:v,tileCacheSize:x,lineType:k="geo",flowStyle:A="basic",areas:j,areaStyle:E={fill:"#f0f0f0",stroke:"#ccc",strokeWidth:.5},edgeColorBy:O,edgeOpacity:S=.6,edgeWidthRange:M=[1,8],edgeLinecap:C="round",colorScheme:$,showParticles:z,particleStyle:L,tooltip:P,annotations:B,margin:I,className:N,selection:D,linkedHover:T,onObservation:R,onClick:W,chartId:_,loading:F,emptyContent:H,frameProps:q={}}=t,G=null!=y?y:!!b,V=co(j),U=bn(T),Z=fn({name:(null==D?void 0:D.name)||"__unused__"}),Y=gn({name:(null==U?void 0:U.name)||"hover",fields:(null==U?void 0:U.fields)||[]}),X=yn(e=>e.pushObservation),K=D?{isActive:Z.isActive,predicate:Z.predicate}:null,J=o||[],Q=i||[],ee=kn(J,O,$),te=r(()=>{const e=new Map;for(const t of Q)e.set(t[a]+"",t);return e},[Q,a]),ne=r(()=>{const e=new Map;for(const t of J)t&&"object"==typeof t&&(null==t.source||e.has(t.source)||e.set(t.source,t),null==t.target||e.has(t.target)||e.set(t.target,t));return e},[J]),oe=l(e=>{var t,n;if(T)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"point"===e.type){const e=ne.get(t[a]+"");e&&Y.onHover(e)}else Y.onHover(t)}else Y.onHover(null);if(R||X){const o={timestamp:Date.now(),chartType:"FlowMap",chartId:_};if(e){let r=e.data||e.datum||e;Array.isArray(r)&&(r=r[0]);const i=Object.assign(Object.assign({},o),{type:"hover",datum:r||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0});R&&R(i),X&&X(i)}else{const e=Object.assign(Object.assign({},o),{type:"hover-end"});R&&R(e),X&&X(e)}}},[T,Y,a,ne,R,_,X]),re=l(e=>{var t,n,o,r;if(e&&W){let o=e.data||e.datum||e;Array.isArray(o)&&(o=o[0]),W(o,{x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0})}if(e&&(R||X)){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n={timestamp:Date.now(),chartType:"FlowMap",chartId:_,type:"click",datum:t||{},x:null!==(o=e.x)&&void 0!==o?o:0,y:null!==(r=e.y)&&void 0!==r?r:0};R&&R(n),X&&X(n)}},[W,R,X,_]),ie=r(()=>{const e="function"==typeof s?s:e=>e[s],t="function"==typeof c?c:e=>e[c];return J.map(n=>{if(!n||"object"!=typeof n||null==n.source||null==n.target)return null;const o=te.get(n.source+""),r=te.get(n.target+"");return o&&r?Object.assign(Object.assign({},n),{coordinates:[{[s]:e(o),[c]:t(o)},{[s]:e(r),[c]:t(r)}]}):null}).filter(Boolean)},[J,te,s,c]),ae=r(()=>{const e=J.filter(e=>e&&"object"==typeof e).map(e=>{var t;return null!==(t=e[u])&&void 0!==t?t:0}).filter(e=>isFinite(e));return 0===e.length?()=>M[0]:w().domain([Math.min(...e),Math.max(...e)]).range(M)},[J,u,M]),se=r(()=>e=>{var t;return{stroke:O?rn(e,O,ee):xn,strokeWidth:ae(null!==(t=e[u])&&void 0!==t?t:0),strokeLinecap:C,opacity:S}},[O,ee,ae,u,S,C]),le=r(()=>K?vn(se,K,Object.assign(Object.assign({},D||{}),{unselectedStyle:{opacity:.15,strokeOpacity:.15,fillOpacity:0}})):se,[se,K,D]),ce=r(()=>()=>({fill:"#333",r:5,fillOpacity:.8}),[]),ue=r(()=>t=>{var n,o,r,i,s,l,c;if((null==t?void 0:t.geometry)||(null==t?void 0:t.properties)||(null===(n=null==t?void 0:t.data)||void 0===n?void 0:n.geometry)){const n=(null===(o=null==t?void 0:t.properties)||void 0===o?void 0:o.name)||(null===(r=null==t?void 0:t.properties)||void 0===r?void 0:r.NAME)||(null==t?void 0:t.name)||(null==t?void 0:t.NAME)||(null===(s=null===(i=null==t?void 0:t.data)||void 0===i?void 0:i.properties)||void 0===s?void 0:s.name)||(null===(c=null===(l=null==t?void 0:t.data)||void 0===l?void 0:l.properties)||void 0===c?void 0:c.NAME);if(n)return e.createElement("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12}},e.createElement("div",{style:{fontWeight:600}},n))}if(null!=(null==t?void 0:t.source)&&null!=(null==t?void 0:t.target)){const n=t[u];return e.createElement("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12}},e.createElement("div",{style:{fontWeight:600}},t.source," → ",t.target),null!=n&&e.createElement("div",{style:{opacity:.7}},"number"==typeof n?n.toLocaleString():n))}const d=(null==t?void 0:t.name)||(null==t?void 0:t.label)||(null==t?void 0:t[a]);return null!=d?e.createElement("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12}},e.createElement("div",{style:{fontWeight:600}},d)):null},[u,a]),de=r(()=>Object.assign({top:10,right:10,bottom:10,left:10},I),[I]),pe=to(F,n.width,n.height),he=pe?null:eo(o,n.width,n.height,H),ye=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({projection:d,lines:ie,points:Q,xAccessor:s,yAccessor:c,lineDataAccessor:"coordinates",lineType:k,flowStyle:A,lineStyle:le,pointStyle:ce},V&&{areas:V,areaStyle:E}),null!=p&&{graticule:p}),null!=h&&{fitPadding:h}),G&&{zoomable:!0}),f&&{zoomExtent:f}),g&&{onZoom:g}),null!=m&&{dragRotate:m}),z&&{showParticles:z}),L&&{particleStyle:L}),b&&{tileURL:b}),v&&{tileAttribution:v}),x&&{tileCacheSize:x}),{size:[n.width,n.height],margin:de,enableHover:!0,tooltipContent:!1===P?()=>null:Qt(P)||ue}),(T||R||W)&&{customHoverBehavior:oe}),(R||W)&&{customClickBehavior:re}),B&&B.length>0&&{annotations:B}),n.title&&{title:n.title}),n.description&&{description:n.description}),n.summary&&{summary:n.summary}),void 0!==n.accessibleTable&&{accessibleTable:n.accessibleTable}),N&&{className:N}),q);return pe||he||e.createElement(Kn,{componentName:"FlowMap",width:n.width,height:n.height},e.createElement(Zt,Object.assign({},ye)))}ho.displayName="ProportionalSymbolMap",yo.displayName="FlowMap";const fo=c(function(i,a){const s=En(i.mode,{width:i.width,height:i.height,showLegend:i.showLegend,title:i.title,description:i.description,accessibleTable:i.accessibleTable,summary:i.summary}),{points:c,lines:d,xAccessor:p="lon",yAccessor:h="lat",nodeIdAccessor:y="id",center:f,costAccessor:g,strength:m=1,lineMode:b="straight",projection:v="mercator",graticule:x,fitPadding:k,zoomable:w,zoomExtent:A,onZoom:j,dragRotate:E,tileURL:O,tileAttribution:S,tileCacheSize:M,transition:C,colorBy:$,colorScheme:z,pointRadius:L=5,tooltip:P,showRings:B=!0,ringStyle:I,showNorth:N=!0,costLabel:D,annotations:T,margin:R,className:W,selection:_,linkedHover:F,onObservation:H,onClick:q,chartId:G,loading:V,emptyContent:U,legendPosition:Z,frameProps:Y={}}=i,X=null!=w?w:!!O,K=c||[],{activeSelectionHook:J,customHoverBehavior:Q,customClickBehavior:ee}=wn({selection:_,linkedHover:F,fallbackFields:$?["string"==typeof $?$:""]:[],onObservation:H,onClick:q,chartType:"DistanceCartogram",chartId:G}),te=kn(K,$,z),ne=r(()=>{const e=e=>({fill:$?rn(e,$,te):xn,fillOpacity:.8,stroke:"#fff",strokeWidth:1,r:L});return J?vn(e,J,_):e},[$,te,L,J,_]),{legend:oe,margin:re,legendPosition:ie}=An({data:K,colorBy:$,colorScale:te,showLegend:s.showLegend,legendPosition:Z,userMargin:R,defaults:{top:10,bottom:10,left:10,right:10}}),ae=r(()=>({center:f,centerAccessor:y,costAccessor:g,strength:m,lineMode:b}),[f,y,g,m,b]),se=r(()=>{if(!d)return;const e="function"==typeof p?p:e=>e[p],t="function"==typeof h?h:e=>e[h],n=new Map;for(const e of K)n.set(e[y]+"",e);return d.map(o=>{if(o.coordinates)return o;const r=n.get(o.source+""),i=n.get(o.target+"");return r&&i?Object.assign(Object.assign({},o),{coordinates:[{[p]:e(r),[h]:t(r)},{[p]:e(i),[h]:t(i)}]}):null}).filter(Boolean)},[d,K,p,h,y]),le=r(()=>t=>{const n=("function"==typeof g?g:e=>e[g])(t);return e.createElement("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12}},e.createElement("div",{style:{fontWeight:600}},t[y]||t.name||t.id||"Point"),null!=n&&e.createElement("div",{style:{opacity:.7}},"Cost: ","number"==typeof n?n.toFixed(1):n))},[g,y]),ce=t(null);u(a,()=>({push:e=>{var t;return null===(t=ce.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=ce.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=ce.current)||void 0===t?void 0:t.removePoint(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o,r;const i=null!==(o=null===(n=ce.current)||void 0===n?void 0:n.removePoint(e))&&void 0!==o?o:[];for(const e of i)null===(r=ce.current)||void 0===r||r.push(t(e));return i},clear:()=>{var e;return null===(e=ce.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=ce.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const[ue,de]=n(null),pe=l(()=>{var e,t;const n=null===(t=null===(e=ce.current)||void 0===e?void 0:e.getCartogramLayout)||void 0===t?void 0:t.call(e);n&&de(e=>e&&e.cx===n.cx&&e.cy===n.cy&&e.maxCost===n.maxCost&&e.availableRadius===n.availableRadius?e:n)},[]);o(()=>{const e=requestAnimationFrame(pe);return()=>cancelAnimationFrame(e)},[pe,m,f,s.width,s.height,K]);const he=r(()=>{if(!B||!ue)return[];const{maxCost:e}=ue;if(0>=e)return[];if(Array.isArray(B))return B.filter(t=>t>0&&e>=t);const t="number"==typeof B?B:Math.min(5,Math.max(2,Math.ceil(e/5))),n=e/t,o=[];for(let e=1;t>=e;e++)o.push(Math.round(n*e*10)/10);return o},[B,ue]),ye=r(()=>{var t,n;if(!ue)return Y.foregroundGraphics||null;const{cx:o,cy:r,maxCost:i,availableRadius:a}=ue,s=Object.assign({stroke:"#999",strokeWidth:.8,strokeDasharray:"4,3",labelColor:"#777",labelSize:10},I),l=null!==(t=re.left)&&void 0!==t?t:10,c=null!==(n=re.top)&&void 0!==n?n:10;return e.createElement("g",null,he.map(t=>{const n=t/i*a;return e.createElement("g",{key:t},e.createElement("circle",{cx:o+l,cy:r+c,r:n,fill:"none",stroke:s.stroke,strokeWidth:s.strokeWidth,strokeDasharray:s.strokeDasharray,opacity:.5}),e.createElement("text",{x:o+l+n+3,y:r+c-2,fontSize:s.labelSize,fill:s.labelColor,fontFamily:"system-ui, sans-serif"},t,D?" "+D:""))}),N&&e.createElement("g",{transform:`translate(${l+24}, ${c+24})`},e.createElement("circle",{r:16,fill:"white",fillOpacity:.85,stroke:"#bbb",strokeWidth:.8}),e.createElement("path",{d:"M0,-11 L3,-3 L1,-4 L1,7 L-1,7 L-1,-4 L-3,-3 Z",fill:"#555",stroke:"none"}),e.createElement("text",{y:-12,textAnchor:"middle",fontSize:7,fontWeight:700,fill:"#555",fontFamily:"system-ui, sans-serif"},"N"),e.createElement("line",{x1:11,y1:0,x2:13,y2:0,stroke:"#bbb",strokeWidth:.8}),e.createElement("line",{x1:-11,y1:0,x2:-13,y2:0,stroke:"#bbb",strokeWidth:.8}),e.createElement("line",{x1:0,y1:11,x2:0,y2:13,stroke:"#bbb",strokeWidth:.8})),Y.foregroundGraphics)},[ue,he,N,D,I,re,Y.foregroundGraphics]),fe=to(V,s.width,s.height),ge=fe?null:eo(c,s.width,s.height,U);no("DistanceCartogram",K,"xAccessor",p),no("DistanceCartogram",K,"yAccessor",h);const me=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({projection:v},null!=c&&{points:K}),se&&{lines:se,lineDataAccessor:"coordinates"}),{xAccessor:p,yAccessor:h,pointIdAccessor:y,pointStyle:ne,projectionTransform:ae}),C&&{transition:{duration:C}}),null!=x&&{graticule:x}),null!=k&&{fitPadding:k}),X&&{zoomable:!0}),A&&{zoomExtent:A}),j&&{onZoom:j}),null!=E&&{dragRotate:E}),O&&{tileURL:O}),S&&{tileAttribution:S}),M&&{tileCacheSize:M}),{size:[s.width,s.height],margin:re,enableHover:!0,tooltipContent:!1===P?()=>null:Qt(P)||le}),oe&&{legend:oe,legendPosition:ie}),(F||H||q)&&{customHoverBehavior:Q}),(H||q)&&{customClickBehavior:ee}),T&&T.length>0&&{annotations:T}),s.title&&{title:s.title}),s.description&&{description:s.description}),s.summary&&{summary:s.summary}),void 0!==s.accessibleTable&&{accessibleTable:s.accessibleTable}),W&&{className:W}),Y),ye&&{foregroundGraphics:ye});return fe||ge||e.createElement(Kn,{componentName:"DistanceCartogram",width:s.width,height:s.height},e.createElement(Zt,Object.assign({ref:ce},me)))});function go(e,t,n){const{featureKey:o,dataKey:r}=n,i=new Map;for(const e of t)i.set(e[r]+"",e);return e.map(e=>{const t=(e=>{const t=o.split(".");let n=e;for(const e of t)n=null==n?void 0:n[e];return(null!=n?n:"")+""})(e),n=i.get(t);return n?Object.assign(Object.assign({},e),{properties:Object.assign(Object.assign({},e.properties),n)}):e})}fo.displayName="DistanceCartogram";export{po as ChoroplethMap,fo as DistanceCartogram,yo as FlowMap,ho as ProportionalSymbolMap,Zt as StreamGeoFrame,go as mergeData,lo as resolveReferenceGeography};