semiotic 3.8.1 → 3.8.3

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 (178) hide show
  1. package/CLAUDE.md +3 -1
  2. package/README.md +54 -52
  3. package/ai/behaviorContracts.cjs +9 -0
  4. package/ai/dist/mcp-server.js +142 -13
  5. package/ai/schema.json +616 -42
  6. package/ai/surface-manifest.json +1 -1
  7. package/ai/system-prompt.md +5 -2
  8. package/dist/chunk-OrdinalBrushOverlay-PXHQYDB2.module.min.js +2 -0
  9. package/dist/chunk-XYBrushOverlay-ECZJJLAJ.module.min.js +1 -0
  10. package/dist/chunk-XYBrushOverlay-EP2SV3UI.module.min.js +2 -0
  11. package/dist/chunk-chunk-255KDHW5.module.min.js +1 -0
  12. package/dist/chunk-chunk-2CCFBTQC.module.min.js +2 -0
  13. package/dist/chunk-chunk-2CXCXRB4.module.min.js +1 -0
  14. package/dist/chunk-chunk-2JGJ5GUG.module.min.js +2 -0
  15. package/dist/chunk-chunk-2RXP3FS3.module.min.js +1 -0
  16. package/dist/chunk-chunk-2WVCH4PL.module.min.js +1 -0
  17. package/dist/chunk-chunk-4TMZXLCR.module.min.js +1 -0
  18. package/dist/chunk-chunk-5APBQXZA.module.min.js +1 -0
  19. package/dist/chunk-chunk-5RKXZQ2P.module.min.js +1 -0
  20. package/dist/chunk-chunk-5UKL5W76.module.min.js +2 -0
  21. package/dist/chunk-chunk-6HSGDMTA.module.min.js +2 -0
  22. package/dist/chunk-chunk-7FW6EGLP.module.min.js +2 -0
  23. package/dist/chunk-chunk-7OEOSCBP.module.min.js +1 -0
  24. package/dist/chunk-chunk-A63CTACR.module.min.js +2 -0
  25. package/dist/chunk-chunk-ANYDWOZF.module.min.js +1 -0
  26. package/dist/chunk-chunk-AZJUDQRM.module.min.js +2 -0
  27. package/dist/chunk-chunk-B6V35LMY.module.min.js +2 -0
  28. package/dist/chunk-chunk-BOSVL645.module.min.js +2 -0
  29. package/dist/chunk-chunk-CA3YDW6F.module.min.js +1 -0
  30. package/dist/chunk-chunk-CP3EN6KZ.module.min.js +1 -0
  31. package/dist/chunk-chunk-DSNGDNJY.module.min.js +1 -0
  32. package/dist/chunk-chunk-EMO5NUGE.module.min.js +2 -0
  33. package/dist/chunk-chunk-F25UA5HT.module.min.js +1 -0
  34. package/dist/chunk-chunk-FRIO6MCV.module.min.js +1 -0
  35. package/dist/chunk-chunk-FYY2ACNJ.module.min.js +2 -0
  36. package/dist/chunk-chunk-G7WFWHAD.module.min.js +2 -0
  37. package/dist/chunk-chunk-GMQ5AYTD.module.min.js +1 -0
  38. package/dist/chunk-chunk-GWSWSPXN.module.min.js +1 -0
  39. package/dist/chunk-chunk-I6C3KR5H.module.min.js +2 -0
  40. package/dist/chunk-chunk-IP2UE74X.module.min.js +1 -0
  41. package/dist/chunk-chunk-J3ELI22J.module.min.js +1 -0
  42. package/dist/chunk-chunk-J3QOW4OE.module.min.js +0 -0
  43. package/dist/chunk-chunk-J3XWETBJ.module.min.js +2 -0
  44. package/dist/chunk-chunk-J5RL6GXU.module.min.js +2 -0
  45. package/dist/chunk-chunk-JCG72SGW.module.min.js +2 -0
  46. package/dist/{semiotic-ai-chunk-OG7BQUUW.module.min.js → chunk-chunk-JJ2OOIET.module.min.js} +0 -1
  47. package/dist/chunk-chunk-JNCHKRIR.module.min.js +2 -0
  48. package/dist/chunk-chunk-KTWEBFMX.module.min.js +2 -0
  49. package/dist/chunk-chunk-L3H6DQCR.module.min.js +2 -0
  50. package/dist/chunk-chunk-M337NY6L.module.min.js +1 -0
  51. package/dist/chunk-chunk-M7VYYHCE.module.min.js +2 -0
  52. package/dist/chunk-chunk-MC35ILYP.module.min.js +2 -0
  53. package/dist/chunk-chunk-N72SWNBV.module.min.js +1 -0
  54. package/dist/chunk-chunk-OBQRFTIL.module.min.js +2 -0
  55. package/dist/chunk-chunk-OQTLSTGI.module.min.js +2 -0
  56. package/dist/chunk-chunk-Q2YADC2V.module.min.js +2 -0
  57. package/dist/chunk-chunk-QRIBHZYW.module.min.js +1 -0
  58. package/dist/chunk-chunk-QSQVBIJA.module.min.js +1 -0
  59. package/dist/chunk-chunk-RCF52Z42.module.min.js +2 -0
  60. package/dist/chunk-chunk-ROP4HI7H.module.min.js +2 -0
  61. package/dist/chunk-chunk-RZH7VZYS.module.min.js +2 -0
  62. package/dist/chunk-chunk-SA3D43RA.module.min.js +2 -0
  63. package/dist/chunk-chunk-SANERMIZ.module.min.js +2 -0
  64. package/dist/chunk-chunk-SIRIJ3DY.module.min.js +1 -0
  65. package/dist/chunk-chunk-SV4XAZ3Q.module.min.js +1 -0
  66. package/dist/chunk-chunk-U66USBWU.module.min.js +1 -0
  67. package/dist/chunk-chunk-UHSZEB74.module.min.js +1 -0
  68. package/dist/chunk-chunk-VVCA3DB7.module.min.js +1 -0
  69. package/dist/chunk-chunk-WCX6U47H.module.min.js +2 -0
  70. package/dist/chunk-chunk-XEVJDUTH.module.min.js +1 -0
  71. package/dist/chunk-chunk-XQYVEKEJ.module.min.js +2 -0
  72. package/dist/chunk-chunk-Y6AXCRVO.module.min.js +1 -0
  73. package/dist/chunk-chunk-YCQYG6J5.module.min.js +2 -0
  74. package/dist/chunk-chunk-YHNZCPOZ.module.min.js +2 -0
  75. package/dist/chunk-chunk-YWZB3KPI.module.min.js +2 -0
  76. package/dist/chunk-chunk-ZCNBUZPL.module.min.js +2 -0
  77. package/dist/chunk-statisticalOverlays-6MVAK5RW.module.min.js +2 -0
  78. package/dist/components/charts/custom/XYCustomChart.d.ts +3 -0
  79. package/dist/components/charts/physics/PhysicalFlowChart.d.ts +7 -0
  80. package/dist/components/charts/realtime/RealtimeHistogram.d.ts +5 -6
  81. package/dist/components/charts/realtime/temporalHistogramConfig.d.ts +11 -0
  82. package/dist/components/charts/shared/areaSeriesData.d.ts +15 -0
  83. package/dist/components/charts/shared/auditAccessibilityText.d.ts +13 -0
  84. package/dist/components/charts/shared/chartMode.d.ts +67 -0
  85. package/dist/components/charts/shared/colorUtils.d.ts +8 -0
  86. package/dist/components/charts/shared/geoStyleDefaults.d.ts +3 -0
  87. package/dist/components/charts/shared/hooks.d.ts +13 -80
  88. package/dist/components/charts/shared/useChartSetup.d.ts +3 -0
  89. package/dist/components/charts/shared/useCustomChartSetup.d.ts +3 -0
  90. package/dist/components/charts/shared/useXYLineStyle.d.ts +3 -2
  91. package/dist/components/charts/shared/xyLineStyle.d.ts +21 -0
  92. package/dist/components/charts/xy/LineChart.d.ts +3 -0
  93. package/dist/components/legendLayout.d.ts +31 -0
  94. package/dist/components/server/serverChartConfigShared.d.ts +29 -0
  95. package/dist/components/server/serverChartConfigs.d.ts +2 -13
  96. package/dist/components/server/serverChartConfigsXY.d.ts +3 -0
  97. package/dist/components/server/serverGaugeOverlay.d.ts +28 -0
  98. package/dist/components/server/staticLegend.d.ts +7 -1
  99. package/dist/components/server/staticSVGChrome.d.ts +60 -2
  100. package/dist/components/stream/GeoPipelineStore.d.ts +2 -0
  101. package/dist/components/stream/GeoSVGOverlay.d.ts +2 -0
  102. package/dist/components/stream/OrdinalBrushOverlay.d.ts +1 -2
  103. package/dist/components/stream/OrdinalBrushOverlayLazy.d.ts +9 -0
  104. package/dist/components/stream/SceneToSVG.d.ts +8 -6
  105. package/dist/components/stream/SceneToSVGGeo.d.ts +10 -0
  106. package/dist/components/stream/SceneToSVGNetwork.d.ts +12 -0
  107. package/dist/components/stream/XYBrushOverlayLazy.d.ts +17 -0
  108. package/dist/components/stream/canvasBackground.d.ts +7 -0
  109. package/dist/components/stream/networkTypes.d.ts +2 -4
  110. package/dist/components/stream/renderBackend.d.ts +14 -0
  111. package/dist/components/stream/sceneToSVGShared.d.ts +51 -0
  112. package/dist/components/types/legendTypes.d.ts +16 -3
  113. package/dist/controls.min.js +1 -1
  114. package/dist/controls.module.min.js +1 -1
  115. package/dist/geo.min.js +1 -1
  116. package/dist/geo.module.min.js +1 -1
  117. package/dist/network.min.js +1 -1
  118. package/dist/network.module.min.js +1 -1
  119. package/dist/ordinal.min.js +1 -1
  120. package/dist/ordinal.module.min.js +1 -1
  121. package/dist/physics-matter.min.js +1 -1
  122. package/dist/physics-matter.module.min.js +1 -1
  123. package/dist/physics-rapier.min.js +1 -1
  124. package/dist/physics-rapier.module.min.js +1 -1
  125. package/dist/physics.min.js +1 -1
  126. package/dist/physics.module.min.js +1 -1
  127. package/dist/realtime.min.js +1 -1
  128. package/dist/realtime.module.min.js +1 -1
  129. package/dist/rough.min.js +1 -1
  130. package/dist/rough.module.min.js +1 -1
  131. package/dist/semiotic-ai-core.min.js +1 -1
  132. package/dist/semiotic-ai-core.module.min.js +1 -1
  133. package/dist/semiotic-ai.min.js +1 -1
  134. package/dist/semiotic-ai.module.min.js +1 -1
  135. package/dist/semiotic-data.min.js +1 -1
  136. package/dist/semiotic-data.module.min.js +1 -1
  137. package/dist/semiotic-experimental.min.js +1 -1
  138. package/dist/semiotic-experimental.module.min.js +1 -1
  139. package/dist/semiotic-realtime-core.min.js +1 -1
  140. package/dist/semiotic-realtime-core.module.min.js +1 -1
  141. package/dist/semiotic-realtime-react.min.js +1 -1
  142. package/dist/semiotic-realtime-react.module.min.js +1 -1
  143. package/dist/semiotic-recipes-core.min.js +1 -1
  144. package/dist/semiotic-recipes-core.module.min.js +1 -1
  145. package/dist/semiotic-recipes-react.min.js +1 -1
  146. package/dist/semiotic-recipes-react.module.min.js +1 -1
  147. package/dist/semiotic-recipes.min.js +1 -1
  148. package/dist/semiotic-recipes.module.min.js +1 -1
  149. package/dist/semiotic-server-edge.min.js +1 -1
  150. package/dist/semiotic-server-edge.module.min.js +1 -1
  151. package/dist/semiotic-server-node.min.js +1 -1
  152. package/dist/semiotic-server-node.module.min.js +1 -1
  153. package/dist/semiotic-themes-core.min.js +1 -1
  154. package/dist/semiotic-themes-core.module.min.js +1 -1
  155. package/dist/semiotic-themes-react.min.js +1 -1
  156. package/dist/semiotic-themes-react.module.min.js +1 -1
  157. package/dist/semiotic-themes.min.js +1 -1
  158. package/dist/semiotic-themes.module.min.js +1 -1
  159. package/dist/semiotic-utils-core.min.js +1 -1
  160. package/dist/semiotic-utils-core.module.min.js +1 -1
  161. package/dist/semiotic-utils-react.min.js +1 -1
  162. package/dist/semiotic-utils-react.module.min.js +1 -1
  163. package/dist/semiotic-utils.min.js +1 -1
  164. package/dist/semiotic-utils.module.min.js +1 -1
  165. package/dist/semiotic-value.min.js +1 -1
  166. package/dist/semiotic-value.module.min.js +1 -1
  167. package/dist/semiotic.min.js +1 -1
  168. package/dist/semiotic.module.min.js +1 -1
  169. package/dist/server.min.js +1 -1
  170. package/dist/server.module.min.js +1 -1
  171. package/dist/xy.min.js +1 -1
  172. package/dist/xy.module.min.js +1 -1
  173. package/package.json +4 -4
  174. package/dist/semiotic-ai-statisticalOverlays-CY4WKR4A.module.min.js +0 -2
  175. package/dist/semiotic-chunk-3FSVZ46U.module.min.js +0 -2
  176. package/dist/semiotic-statisticalOverlays-UOMSFKVJ.module.min.js +0 -2
  177. package/dist/xy-chunk-IWD6IB6V.module.min.js +0 -2
  178. package/dist/xy-statisticalOverlays-7RWG6LJT.module.min.js +0 -2
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{useRef as e,useState as t,useEffect as n,useMemo as o,useCallback as r,useImperativeHandle as i,forwardRef as a,memo as s}from"react";import{geoPath as l}from"d3-geo";import{quadtree as c}from"d3-quadtree";var u=class{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;return{next:()=>this._size>e?{done:!1,value:this.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();let n=0,o=[];t.length>e&&(n=t.length-e,o=t.slice(0,n)),this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(let e=n;t.length>e;e++)this.push(t[e]);return o}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]:{...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 d(e,t,n){return e+(t-e)*n}function h(e,t,n){if(1>=n)return 1;const o=n-1;return function(e){const t=Math.max(0,Math.min(1,e.minOpacity??.1));if(Number.isNaN(e.age))return 1;if(e.age===1/0)return t;if(!Number.isFinite(e.extent)||0>=e.extent)return 1;const n=Math.max(0,e.age);if("step"===e.type)return(e.threshold??.5*e.extent)>n?1:t;if("exponential"===e.type){const o=e.halfLife??e.extent/2;return t+Math.pow(.5,n/(o>0?o:e.extent/2))*(1-t)}return t+Math.max(0,Math.min(1,1-n/e.extent))*(1-t)}({age:o-t,extent:o,type:e.type,halfLife:e.halfLife??n/2,threshold:e.stepThreshold??.5*n,minOpacity:e.minOpacity??.1})}function f(e,t,n){const o=e.duration??500,r=n-t;return o>r?1-r/o:0}function p(e,t,n,o){let r=!1;return t>0?(e._pulseIntensity!==t&&(e._pulseIntensity=t,r=!0),e._pulseColor!==n&&(e._pulseColor=n,r=!0),e._pulseGlowRadius!==o&&(e._pulseGlowRadius=o,r=!0),r):(0!==e._pulseIntensity&&(e._pulseIntensity=0,r=!0),void 0!==e._pulseColor&&(e._pulseColor=void 0,r=!0),void 0!==e._pulseGlowRadius&&(e._pulseGlowRadius=void 0,r=!0),r)}import{scaleOrdinal as m}from"d3-scale";function y(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function g(e,t,n){const o=e=>e.toString(16).padStart(2,"0");return`#${o(e)}${o(t)}${o(n)}`}function b(e){const t=e.map(y),n=t.length-1;return e=>{if(0>=e){const[e,n,o]=t[0];return g(e,n,o)}if(e>=1){const[e,o,r]=t[n];return g(e,o,r)}const o=e*n,r=Math.floor(o),i=o-r,[a,s,l]=t[r],[c,u,d]=t[r+1];return g(Math.round(a+(c-a)*i),Math.round(s+(u-s)*i),Math.round(l+(d-l)*i))}}var v=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],x=b(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),w=b(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),k=b(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),S=b(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),A=b(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),C=b(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),M=b(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),R=b(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),L=b(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),j=b(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),P=b(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),I=b(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),T={blues:x,reds:w,greens:k,viridis:M,oranges:S,purples:A,greys:C,plasma:R,inferno:L,magma:j,cividis:P,turbo:I};function D(e){return e&&T[e]||x}b(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),b(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),b(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),b(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),b(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),b(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),b(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]);var z={category10:v,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],...T},O=v,N=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],B=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 E(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")||B.has(t)}(o)?n(o):o}const o=e?.[t]+"";return n?n(o):O[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))%O.length]}function W(e,t){if(null==t||!Object.prototype.hasOwnProperty.call(e,t))return;const n=e[t];return"string"==typeof n&&n.length>0?n:void 0}function _(e,t,n="category10"){if(n&&"object"==typeof n&&!Array.isArray(n)){const e=n;return t=>W(e,t)??"#999"}const o=Array.from(new Set(e.map(e=>e?.[t]).filter(e=>null!=e).map(e=>e+""))),r=o.every(e=>!isNaN(Number(e)));if(Array.isArray(n))return m().domain(o).range(n).unknown("#999");const i=z[n]||z.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:O;return m().domain(o).range(e).unknown("#999")}}function H(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;if(a===i)return(s+l)/2;let c=(r-i)/(a-i);return 0>c?c=0:c>1&&(c=1),s+c*(l-s)}function F(e,t){const n=t&&"object"==typeof t&&!Array.isArray(t)?t:void 0;return 0===e.length?e=>n&&W(n,e)||"#4e79a7":t=>{if(n){const e=W(n,t);if(e)return e}let o=0;for(let e=0;t.length>e;e++)o=31*o+t.charCodeAt(e)|0;return e[Math.abs(o)%e.length]??"#4e79a7"}}function $(e){return null!=e&&!1!==e&&""!==e&&(!Array.isArray(e)||e.some($))}function G(e,t,n){e.has(t)||(e.add(t),console.warn(n))}import{geoMercator as q,geoEqualEarth as V,geoAlbersUsa as U,geoOrthographic as Z,geoNaturalEarth1 as Y,geoEquirectangular as X}from"d3-geo";var Q={mercator:q,equalEarth:V,albersUsa:U,orthographic:Z,naturalEarth:Y,equirectangular:X};function K(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}function J(e){return e?"function"==typeof e?e:t=>t[e]:e=>e.coordinates||e.data||[]}function ee(e,t,n){return e?"function"==typeof e?{...n,...e(t)}:{...n,...e}:{...n}}function te(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 ne(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 oe(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 re(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]]}import{scaleLinear as ie}from"d3-scale";function ae(e){let t=1/0,n=-1/0;for(const o of e)t>o&&(t=o),o>n&&(n=o);return[t,n]}function se(e,t,n,o){const r=e.push(t);return n&&n.push(o),r}var le={data:"data",domain:"domain",layout:"layout","scene-geometry":"sceneGeometry","scene-style":"sceneStyle","data-paint":"dataPaint","interaction-paint":"interactionPaint",overlay:"overlay",accessibility:"accessibility",evidence:"evidence"};function ce(e,t){const n={...e};for(const e of t)n[le[e]]++;return n}function ue(e,t,n){const o=new Set(t);return{changeSet:{...e,...e.keys?{keys:[...e.keys]}:{}},changed:o,revisions:ce(n,o)}}var de=class{constructor(){this.revisions={data:0,domain:0,layout:0,sceneGeometry:0,sceneStyle:0,dataPaint:0,interactionPaint:0,overlay:0,accessibility:0,evidence:0},this.latest=ue({kind:"initialize"},[],this.revisions),this.listeners=new Set}get last(){return this.latest}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}record(e,t){const n=ue(e,t,this.revisions);this.revisions=n.revisions,this.latest=n;for(const e of[...this.listeners])e();return n}},he=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],fe=["scene-style","data-paint","accessibility","evidence"],pe=(e,t)=>({retainedData:e,invalidations:t}),me=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],ye=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],ge=["scene-geometry","data-paint","accessibility","evidence"],be=["scene-style","data-paint","accessibility","evidence"],ve=["overlay","accessibility","evidence"],xe=[],we={xAccessor:pe("rebuild",me),yAccessor:pe("rebuild",me),lineDataAccessor:pe("rebuild",me),pointIdAccessor:pe("rebuild",ge),lineIdAccessor:pe("rebuild",ge),windowSize:pe("rebuild",me),projection:pe("preserve",ye),projectionExtent:pe("preserve",ye),fitPadding:pe("preserve",ye),lineType:pe("preserve",ye),flowStyle:pe("preserve",ye),graticule:pe("preserve",ye),projectionTransform:pe("preserve",ye),customLayout:pe("preserve",ye),layoutConfig:pe("preserve",ye),layoutMargin:pe("preserve",ye),areaStyle:pe("preserve",be),pointStyle:pe("preserve",["scene-geometry","scene-style","data-paint","accessibility","evidence"]),lineStyle:pe("preserve",be),colorScheme:pe("preserve",be),themeCategorical:pe("preserve",be),themeDiverging:pe("preserve",be),themeSemantic:pe("preserve",be),themeSequential:pe("preserve",be),decay:pe("preserve",be),pulse:pe("preserve",be),layoutSelection:pe("preserve",be),annotations:pe("preserve",ve),autoPlaceAnnotations:pe("preserve",ve),clock:pe("preserve",xe),transition:pe("preserve",xe),introAnimation:pe("preserve",xe),onLayoutError:pe("preserve",xe)},ke=pe("preserve",ye),Se=class{constructor(){this.tracker=new de}get last(){return this.tracker.last}subscribe(e){return this.tracker.subscribe(e)}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},he)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},fe):this.recordNoop("restyle")}recordConfig(e,t={}){const n=function(e){let t="preserve";const n=new Set;for(const o of e){const e=we[o]??ke;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)n.add(t)}return{retainedData:t,invalidations:n}}(e),o=new Set(n.invalidations);return t.retainedDataChanged&&o.add("data"),this.tracker.record({kind:"config",keys:e},o)}},Ae=new WeakMap;import{geoDistance as Ce,geoGraticule as Me,geoInterpolate as Re}from"d3-geo";function Le(e){if(null==e)return 0;if("number"==typeof e&&Number.isFinite(e)&&e>=0&&.5>e)return e;throw new RangeError(`[semiotic] fitPadding must be a finite fraction in [0, 0.5); received ${e+""}.`)}var je=class e{constructor(e){this.updateResults=new Se,this.scene=[],this.scales=null,this.version=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._customLayoutFailedThisBuild=!1,this._quadtree=null,this._maxPointRadius=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._hasRenderedOnce=!1,this.config=function(e){return{...e,fitPadding:Le(e.fitPadding)}}(e)}currentTime(){return this.config.clock?.()??("undefined"!=typeof performance?performance.now():Date.now())}getConfiguredWindowSize(){const e=this.config.windowSize??500;if(!Number.isInteger(e)||1>e)throw Error("GeoPipelineStore windowSize must be a positive integer");return e}retainNewestLines(e=this.getConfiguredWindowSize()){this.lineData.length>e&&(this.lineData=this.lineData.slice(-e))}resizeStreamingWindow(e){if(this.pointBuffer){const t=this.pointBuffer.toArray(),n=this.timestampBuffer?.toArray()??[],o=t.slice(-e),r=n.slice(-o.length),i=this.currentTime();this.pointBuffer=new u(e),this.timestampBuffer=new u(e),o.forEach((e,t)=>{this.pointBuffer.push(e),this.timestampBuffer.push(r[t]??i)})}this.retainNewestLines(e)}updateConfig(e){const t=function(e){return"fitPadding"in e?{...e,fitPadding:Le(e.fitPadding)}:e}(e),n=this.config,o=this.getConfiguredWindowSize(),r=Object.keys(t).filter(e=>t[e]!==n[e]);this.config={...this.config,...t};const i=this.getConfiguredWindowSize(),a=this.streaming&&i!==o;a&&(this.resizeStreamingWindow(i),this.version++),"customLayout"in t&&!t.customLayout&&(this.lastCustomLayoutFailure=null),this.updateResults.recordConfig(r,{retainedDataChanged:a})}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}setAreas(e){this.areas=e,this.updateResults.recordData("replace",e.length)}setAreasWithResult(e){return this.setAreas(e),this.updateResults.last}setPoints(e){this.pointData=e.slice(),this.pointBuffer=null,this.timestampBuffer=null,this.streaming=!1,this.updateResults.recordData("replace",e.length)}setPointsWithResult(e){return this.setPoints(e),this.updateResults.last}setLines(e){this.lineData=e.slice(),this.streaming&&this.retainNewestLines(),this.updateResults.recordData("replace",e.length)}setLinesWithResult(e){return this.setLines(e),this.updateResults.last}initStreaming(e){void 0!==e&&e!==this.config.windowSize&&(this.config={...this.config,windowSize:e});const t=this.getConfiguredWindowSize(),n=this.pointBuffer?this.pointBuffer.toArray():this.pointData,o=this.timestampBuffer?.toArray()??[],r=n.slice(-t),i=o.slice(-r.length),a=this.currentTime();this.pointBuffer=new u(t),this.timestampBuffer=new u(t),r.forEach((e,t)=>{this.pointBuffer.push(e),this.timestampBuffer.push(i[t]??a)}),this.pointData=[],this.retainNewestLines(t),this.streaming=!0}pushPoint(e){this.pointBuffer||this.initStreaming();const t=this.currentTime();se(this.pointBuffer,e,this.timestampBuffer,t),this.lastIngestTime=t,this.updateResults.recordData("ingest",1)}pushPointWithResult(e){return this.pushPoint(e),this.updateResults.last}pushMany(e){this.pointBuffer||this.initStreaming();const t=this.currentTime();for(const n of e)se(this.pointBuffer,n,this.timestampBuffer,t);this.lastIngestTime=t,this.updateResults.recordData("ingest",e.length)}pushManyWithResult(e){return this.pushMany(e),this.updateResults.last}pushLine(e){null!=e&&"object"==typeof e?(this.streaming||this.initStreaming(),this.lineData.push(e),this.retainNewestLines(),this.version++,this.updateResults.recordData("ingest",1)):this.updateResults.recordNoop("ingest")}pushManyLines(e){if(!Array.isArray(e)||0===e.length)return void this.updateResults.recordNoop("ingest");const t=e.filter(e=>null!=e&&"object"==typeof e);if(0!==t.length){this.streaming||this.initStreaming();for(const e of t)this.lineData.push(e);this.retainNewestLines(),this.version++,this.updateResults.recordData("ingest",t.length)}else this.updateResults.recordNoop("ingest")}removeLine(e){const{lineIdAccessor:t}=this.config;if(!t)throw Error("removeLine() requires lineIdAccessor to be configured");const n="function"==typeof t?t:e=>e[t],o=new Set(Array.isArray(e)?e:[e]),r=[];return this.lineData=this.lineData.filter(e=>!o.has(n(e)+"")||(r.push(e),!1)),r.length>0?(this.version++,this.updateResults.recordData("remove",r.length)):this.updateResults.recordNoop("remove"),r}getLines(){return this.lineData.slice()}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)+"");!function(e,t,n){if(!t||0===t.size)return;const o=new Set;if(e.forEach((e,t)=>{n(e)&&o.add(t)}),0===o.size)return;const r=t.toArray();t.clear();for(let e=0;r.length>e;e++)o.has(e)||t.push(r[e])}(this.pointBuffer,this.timestampBuffer,e);const t=this.pointBuffer.remove(e);return t.length>0?(this.version++,this.updateResults.recordData("remove",t.length)):this.updateResults.recordNoop("remove"),t}{const e=[];return this.pointData=this.pointData.filter(t=>!o.has(n(t)+"")||(e.push(t),!1)),e.length>0?(this.version++,this.updateResults.recordData("remove",e.length)):this.updateResults.recordNoop("remove"),e}}clear(){this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.timestampBuffer=null,this.streaming=!1,this.scene=[],this.scales=null,this._hasRenderedOnce=!1,this.activeTransition=null,this.prevPositions=null,this._quadtree=null,this._maxPointRadius=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._customLayoutFailedThisBuild=!1,this.version++,this.updateResults.recordData("clear")}restyleScene(e){const t=this._customRestyle;if(t){for(const n of this.scene){const o=this._baseStyles.get(n)??n.style,r=t(n,e);n.style=r?{...o,...r}:o}this.markStylePaintPending(),this.updateResults.recordRestyle(!0)}else this.updateResults.recordRestyle(!1)}computeScene(e){const{config:t}=this,n=this.projection,o=this.geoPath,r=this.scales,i=this.baseScale,a=[...this.baseTranslate],s=[...this.baseRotation],c=this.scene;this.projection=function(e){if(!e)return V();if("string"==typeof e){const t=Q[e];return t?t():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${e}", falling back to equalEarth`),V())}if("object"==typeof e&&"type"in e){const t=Q[e.type],n=t?t():V();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=l(this.projection),this.fitProjection(e),this.geoPath=l(this.projection);const u=this.projection;this.scales={projection:u,geoPath:this.geoPath,projectedPoint:(e,t)=>u([e,t]),invertedPoint:(e,t)=>u.invert?u.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const d=this.buildSceneNodes(e);if(this._customLayoutFailedThisBuild)!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.projection=n,this.geoPath=o,this.scales=r,this.baseScale=i,this.baseTranslate=a,this.baseRotation=s):(this.scene=[],this.rebuildQuadtree());else{if(this.scene=d,this.rebuildQuadtree(),t.projectionTransform&&this.applyCartogramTransform(t.projectionTransform,e),t.decay&&this.streaming&&this.applyDecay(),t.pulse&&this.streaming&&this.applyPulse(),t.transition&&!this._hasRenderedOnce&&this.scene.length>0&&t.introAnimation){const t=e.width/2,n=e.height/2,o=this.scene.filter(e=>"point"===e.type).map(e=>({...e,x:t,y:n}));o.length>0&&this.startTransition(o)}this._hasRenderedOnce=!0,t.transition&&c.length>0&&this.startTransition(c),this.version++}}fitProjection(e){const t=this.projection,n=this.config,o=[...this.areas],r=K(n.xAccessor,"lon"),i=K(n.yAccessor,"lat"),a=this.getPoints();if(a.length>0){const e=a.map(e=>[r(e),i(e)]);o.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:e}})}const s=J(n.lineDataAccessor);for(const e of this.lineData){const t=s(e);if(t&&t.length>0){const e=t.map(e=>[r(e),i(e)]);o.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:e}})}}if(0!==o.length){if(n.projectionExtent){const[[o,r],[i,a]]=n.projectionExtent;t.fitExtent([[0,0],[e.width,e.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[o,r],[i,r],[i,a],[o,a],[o,r]]]}})}else if(t.clipAngle&&(t.clipAngle()??0)>0){const o=n.fitPadding??0,r=Math.min(e.width,e.height);t.scale(r/2-r*o),t.translate([e.width/2,e.height/2])}else{const r=n.fitPadding??0,i=e.width*r,a=e.height*r;t.fitExtent([[i,a],[e.width-i,e.height-a]],{type:"FeatureCollection",features:o})}this.baseScale=t.scale(),this.baseTranslate=t.translate(),this.baseRotation=t.rotate?.()??[0,0,0]}}applyZoomTransform(e,t){const n=this.projection;if(!n)return;const o=this.geoPath,r=this.scales,i=n.scale(),a=[...n.translate()],s=this.currentZoom;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=l(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._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(n.scale(i),n.translate(a),this.currentZoom=s,this.geoPath=o,this.scales=r):(this.scene=[],this.rebuildQuadtree()):(this.scene=c,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}applyZoomScale(e,t){const n=this.projection;if(!n)return;const o=this.geoPath,r=this.scales,i=n.scale(),a=[...n.translate()],s=this.currentZoom;n.scale(this.baseScale*e),n.translate(this.baseTranslate),this.currentZoom=e,this.geoPath=l(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._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(n.scale(i),n.translate(a),this.currentZoom=s,this.geoPath=o,this.scales=r):(this.scene=[],this.rebuildQuadtree()):(this.scene=c,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}applyRotation(e,t){const n=this.projection;if(!n||!n.rotate)return;const o=this.geoPath,r=this.scales,i=[...n.rotate()];n.rotate(e),this.geoPath=l(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._customLayoutFailedThisBuild=!1;const a=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(n.rotate(i),this.geoPath=o,this.scales=r):(this.scene=[],this.rebuildQuadtree()):(this.scene=a,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}setRotation(e){const t=this.projection;t&&t.rotate&&t.rotate(e)}getRotation(){return this.projection?.rotate?.()??this.baseRotation}getBaseProjectionState(){return{scale:this.baseScale,translate:[...this.baseTranslate]}}getPoints(){return this.streaming&&this.pointBuffer?this.pointBuffer.toArray():this.pointData}rebuildQuadtree(){let t=0,n=0;for(const e of this.scene)"point"===e.type&&(n++,e.r>t&&(t=e.r));if(this._maxPointRadius=t,e.QUADTREE_THRESHOLD>=n)return void(this._quadtree=null);const o=Array(n);let r=0;for(const e of this.scene)"point"===e.type&&(o[r++]=e);this._quadtree=c().x(e=>e.x).y(e=>e.y).addAll(o)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(e){this._customLayoutFailedThisBuild=!1;const{config:t}=this,n=this.projection,o=this.geoPath;if(t.customLayout&&this.scales){const n=t.layoutMargin??{top:0,right:0,bottom:0,left:0},o=function(e,t,n){if(e&&"object"==typeof e&&!Array.isArray(e)){const t=Object.values(e).filter(e=>"string"==typeof e&&e.length>0);if(t.length>0)return t}if(Array.isArray(e)&&e.length>0)return e;if("string"==typeof e){const t=z[e];if(Array.isArray(t)&&t.length>0)return t}return t&&t.length>0?t:n}(t.colorScheme,t.themeCategorical,N),r={areas:this.areas.slice(),points:this.getPoints().slice(),lines:this.lineData.slice(),scales:this.scales,dimensions:{width:e.width,height:e.height,margin:n,plot:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:t.themeSemantic??{},categorical:[...o]},resolveColor:F(o,t.colorScheme),config:t.layoutConfig??{},selection:t.layoutSelection??null};let i;try{i=t.customLayout(r)}catch(e){const n=null!==this.lastCustomLayoutResult,o=function(e,t,n,o){const r=function(e){if(e instanceof Error)return{name:e.name||"Error",message:e.message||"Custom layout threw."};if("string"==typeof e)return{name:"Error",message:e};if(null==e)return{name:"Error",message:"Custom layout threw a nullish value."};try{return{name:"Error",message:e+""}}catch{return{name:"Error",message:"Custom layout threw a non-stringifiable value."}}}(t),i="network"===e?"customNetworkLayout":"customLayout";return{code:"CUSTOM_LAYOUT_ERROR",severity:"error",phase:"layout",component:e,source:i,message:`Semiotic ${e} ${i} failed: ${r.message}`,error:r,recovery:n?"preserved-last-good-scene":"empty-scene",preservedLastGoodScene:n,affectedRevision:o}}("geo",e,n,this.version);this.lastCustomLayoutFailure=o,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] geo customLayout threw:",e);try{t.onLayoutError?.(o)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return n?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}const a=i.nodes??[];if(this.customLayoutOverlays=i.overlays??null,this.lastCustomLayoutResult=i,this.lastCustomLayoutFailure=null,this._customRestyle=i.restyle,this.hasCustomRestyle=!!i.restyle,this._baseStyles=new WeakMap,this.hasCustomRestyle){for(const e of a)this._baseStyles.set(e,e.style);this.restyleScene(t.layoutSelection??null)}return function(e){if("production"===process.env.NODE_ENV)return;const{label:t,nodes:n,overlays:o,warned:r}=e;$(o)&&0===n.length&&G(r,"overlay-only",`[semiotic] ${t} returned overlays but no data-bearing scene nodes. Overlays do not participate in hover, selection, transitions, SSR evidence, or accessibility tables. Emit at least one scene node with a datum, or mark the overlay-only chart as intentionally decorative.`),n.length>0&&n.every(e=>null==e.datum)&&G(r,"null-datums",`[semiotic] ${t} returned scene nodes, but every scene-node datum is null. Hover, callbacks, selection, and tooltip helpers need data-bearing nodes. Attach a user-facing datum to each interactive node, or set interactive overlays outside the chart.`)}({label:"geo customLayout",nodes:a,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),a}return this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,function({config:e,projection:t,path:n,areas:o,points:r,lines:i,layout:a}){const s=K(e.xAccessor,"lon"),l=K(e.yAccessor,"lat"),c=[],u=function(e){return{fill:e.themeSemantic?.surface||"#e0e0e0",stroke:e.themeSemantic?.border||"#999",strokeWidth:.5,fillOpacity:1}}(e),d=function(e){return{stroke:e.themeSemantic?.primary||"#4e79a7",strokeWidth:1.5,fill:"none"}}(e),h=function(e){return{fill:e.themeSemantic?.primary||"#4e79a7",r:4,fillOpacity:.8}}(e);if(e.graticule){const t=!0===e.graticule?{}:e.graticule,o=Me();t.step&&o.step(t.step);const r=n(o())||"";r&&c.push({type:"geoarea",pathData:r,centroid:[a.width/2,a.height/2],bounds:[[0,0],[a.width,a.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 t of o){const o=n(t);if(!o)continue;const r=n.centroid(t),i=n.bounds(t),a=n.area(t);c.push({type:"geoarea",pathData:o,centroid:r,bounds:i,screenArea:a,style:ee(e.areaStyle,t,u),datum:t,interactive:!0})}const f=J(e.lineDataAccessor);for(const n of i){const o=f(n);if(!o||2>o.length)continue;let r=[];if("geo"===e.lineType){const e=Array(o.length);for(let t=0;o.length>t;t++)e[t]=[s(o[t]),l(o[t])];for(let n=0;e.length-1>n;n++){const o=e[n],i=e[n+1],a=Ce(o,i)||0,s=Math.max(2,Math.ceil(a/(Math.PI/180))),l=Re(o,i);for(let e=0;s>=e;e++){if(n>0&&0===e)continue;const o=t(l(e/s));null!=o&&r.push(o)}}}else for(let e=0;o.length>e;e++){const n=o[e],i=t([s(n),l(n)]);null!=i&&r.push(i)}if(2>r.length)continue;const i=ee(e.lineStyle,n,d),u="number"==typeof i.strokeWidth?i.strokeWidth:1;2!==o.length||2>r.length||"arc"!==e.flowStyle?2!==o.length||2>r.length||"offset"!==e.flowStyle||(r="geo"===e.lineType?oe(r,u):re(r[0],r[r.length-1],0,0,u)):r=ne(r[0],r[r.length-1]);const h=te(r,a.width);if(h.length>1)for(const e of h)2>e.length||c.push({type:"line",path:e,style:{...i,_edgeFade:!0},datum:n});else c.push({type:"line",path:2>r.length&&h[0]||r,style:i,datum:n})}const p=e.pointIdAccessor?"function"==typeof e.pointIdAccessor?e.pointIdAccessor:t=>t[e.pointIdAccessor]:null,m=t.clipAngle?t.clipAngle()??0:0,y=m>0?m*Math.PI/180:null,g=t.rotate?t.rotate():[0,0,0],b="function"==typeof t.center?t.center():[0,0],v=[(b[0]??0)-g[0],(b[1]??0)-g[1]];for(const n of r){const o=s(n),r=l(n);if(null!=y&&Ce([o,r],v)>y)continue;const i=t([o,r]);if(!i)continue;const a=e.pointStyle?e.pointStyle(n):{...h},u={type:"point",x:i[0],y:i[1],r:a.r||4,style:a,datum:n,pointId:p?p(n)+"":void 0};c.push(u)}return c}({config:t,projection:n,path:o,areas:this.areas,points:this.getPoints(),lines:this.lineData,layout:e})}applyCartogramTransform(e,t){const n=function(e,t,n,o){const r=e.filter(e=>"point"===e.type);if(2>r.length)return null;const i=t.strength??1;if(0===i)return null;const a=t.centerAccessor?"function"==typeof t.centerAccessor?t.centerAccessor:e=>e[t.centerAccessor]:e=>e.id,s="function"==typeof t.costAccessor?t.costAccessor:e=>e[t.costAccessor],l=r.find(e=>e.datum&&a(e.datum)+""==t.center+"");if(!l)return"production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${t.center}" not found in point data`),null;const c=l.x,u=l.y,d=function(e,t=-1/0){let n=t;for(const t of e)t>n&&(n=t);return n}(r.map(e=>e.datum?s(e.datum):NaN).filter(e=>isFinite(e)&&e>=0),1),h=Math.min(n.width,n.height)/2,f=ie().domain([0,d]).range([0,h]);o>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.");for(let t=e.length-1;t>=0;t--){const n=e[t];"geoarea"===n.type&&n.interactive&&e.splice(t,1)}for(const e of r){if(e===l)continue;if(!e.datum)continue;const t=Math.atan2(e.y-u,e.x-c),n=Math.sqrt((e.x-c)**2+(e.y-u)**2),o=s(e.datum),r=n+((isFinite(o)?f(o):n)-n)*i;e.x=c+Math.cos(t)*r,e.y=u+Math.sin(t)*r}const p=n.width/2,m=n.height/2,y=p-l.x,g=m-l.y;if(Math.abs(y)>.5||Math.abs(g)>.5)for(const e of r)e.x+=y,e.y+=g;const b={cx:p,cy:m,maxCost:d,availableRadius:h},v=e.filter(e=>"line"===e.type);if(v.length>0&&"fractional"!==t.lineMode){const e=new Map;for(const t of r)t.pointId&&e.set(t.pointId,[t.x,t.y]);for(const t of v){const n=t.datum?.source,o=t.datum?.target;if(n&&o){const r=e.get(n+""),i=e.get(o+"");r&&i&&(t.path=[r,i])}}}return b}(this.scene,e,t,this.areas.length);n&&(this.cartogramLayout=n)}applyDecay(){const e=this.config.decay;if(!e||!this.pointBuffer)return;const t=this.pointBuffer.size;if(0===t)return;const n=this.scene.filter(e=>"point"===e.type);for(let o=0;n.length>o;o++){const r=h(e,o,t);n[o]._decayOpacity=r,n[o].style={...n[o].style,opacity:r}}}applyPulse(e=this.currentTime()){const t=this.config.pulse;if(!t||!this.timestampBuffer)return!1;const n=this.scene.filter(e=>"point"===e.type),o=this.timestampBuffer.toArray(),r=t.color||"rgba(255,255,255,0.6)",i=t.glowRadius??4;let a=!1;for(let s=0;n.length>s&&o.length>s;s++){const l=f(t,o[s],e);a=p(n[s],l,r,i)||a}return a}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(e)}hasActivePulsesAt(e){return!!this.config.pulse&&function(e,t,n=("undefined"!=typeof performance?performance.now():Date.now())){if(!t||0===t.size)return!1;const o=e.duration??500,r=t.peek();return null!=r&&o>n-r}(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}startTransition(e){const t=this.config.transition?.duration??300;if(0>=t)return;const n=new Map;for(const t of e)"point"===t.type&&t.pointId&&n.set(t.pointId,[t.x,t.y]);const o=this.scene.filter(e=>"point"===e.type);let r=!1;for(const e of o)if(e.pointId){const t=n.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)&&(r=!0))}for(const e of o)e.pointId&&!n.has(e.pointId)&&(e._targetOpacity=e.style?.opacity??1,e.style={...e.style,opacity:0},r=!0);r&&(this.activeTransition={startTime:this.currentTime(),duration:t})}cancelIntroAnimation(){this.activeTransition=null}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=d(e.x,e._targetX,n),e.y=d(t,e._targetY,n)}null!=e._targetOpacity&&(e.style={...e.style,opacity:e._targetOpacity*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),null!=e._targetOpacity&&(e.style={...e.style,opacity:e._targetOpacity},e._targetOpacity=void 0);return this.activeTransition=null,!1}return!0}};je.QUADTREE_THRESHOLD=500;var Pe=je;Object.assign(Pe.prototype,{getLastUpdateResult:function(){return this.updateResults.last},getUpdateSnapshot:function(){return this.updateResults.last},subscribeUpdateResult:function(e){return this.updateResults.subscribe(e)},setLayoutSelection:function(e){this.config.layoutSelection=e},markStylePaintPending:function(){Ae.set(this,!0)},consumeStylePaintPending:function(){const e=!0===Ae.get(this);return Ae.delete(this),e}});import{memo as Ie,useEffect as Te,useRef as De}from"react";var ze={sceneGeometry:0,layout:0,domain:0};function Oe(e){const{domain:t,layout:n,sceneGeometry:o}=e.revisions;return{domain:t,layout:n,sceneGeometry:o}}function Ne(e,t){return{sceneGeometry:Math.max(e.sceneGeometry,t.sceneGeometry),layout:Math.max(e.layout,t.layout),domain:Math.max(e.domain,t.domain)}}var Be="production"!==process.env.NODE_ENV,Ee={revisions:ze,signature:"",sawSignals:!1,wasUnconsumed:!1,warnUnconsumed:!1},We=class{constructor(e="scene host"){this.hostName=e,this.lastConsumed=ze,this.lastObserved=ze,this.lastDuplicateWarning="",this.lastUnconsumedWarning=""}observeUpdateResult(e){Be&&(this.lastObserved=Ne(this.lastObserved,Oe(e)))}beforeCompute(e,t){if(!Be)return Ee;const n=Ne(Oe(e),this.lastObserved),o=function(e){return`${e.sceneGeometry}|${e.layout}|${e.domain}`}(n),r=!((i=n).sceneGeometry===(a=this.lastConsumed).sceneGeometry&&i.layout===a.layout&&i.domain===a.domain);var i,a;return{revisions:n,signature:o,sawSignals:e.changed.has("scene-geometry")||e.changed.has("layout")||e.changed.has("domain"),wasUnconsumed:r,warnUnconsumed:!t&&r&&this.lastUnconsumedWarning!==o}}afterCompute(e,t,n){if(Be){if(t&&e.wasUnconsumed&&(this.lastConsumed=e.revisions),e.warnUnconsumed&&!t)return console.warn(`[semiotic] ${this.hostName} observed scene-affecting revisions without a scene rebuild: ${e.signature}.`),void(this.lastUnconsumedWarning=e.signature);t&&e.sawSignals&&!e.wasUnconsumed&&!n&&this.lastDuplicateWarning!==e.signature?(console.warn(`[semiotic] ${this.hostName} performed scene rebuild with unchanged scene revisions: ${e.signature}.`),this.lastDuplicateWarning=e.signature):t&&!e.sawSignals&&(this.lastDuplicateWarning="")}}},_e=Ie(function({store:e,diagnostics:t}){return Te(()=>{const n=()=>t.observeUpdateResult(e.getUpdateSnapshot());return n(),e.subscribeUpdateResult(n)},[t,e]),null});function He(e,t=30){return Math.max((e??4)+5,12,t)}var Fe=[40,40],$e=[.5,.5];function Ge(e,t){const[n,o]=e.viewBox??Fe,[r,i]=e.anchor??$e,a=o>0?o:1,s=Math.max(0,t)/a,l=(n>0?n:a)*s,c=a*s;return{width:l,height:c,scale:s,offsetX:-r*l,offsetY:-i*c}}function qe(e,t){const n=Ge(e,t),o=[[n.offsetX,n.offsetY],[n.offsetX+n.width,n.offsetY],[n.offsetX,n.offsetY+n.height],[n.offsetX+n.width,n.offsetY+n.height]];let r=0;for(const[e,t]of o){const n=Math.sqrt(e*e+t*t);n>r&&(r=n)}return r}function Ve(e,t,n,o){if("none"!==e)return"color"===e||null==e?t??o:"accent"===e?n:e}var Ue=null;function Ze(e){if("undefined"==typeof Path2D)return null;Ue||(Ue=new Map);const t=Ue.get(e);if(t)return t;const n=new Path2D(e);return Ue.size>1024&&Ue.clear(),Ue.set(e,n),n}function Ye(e,t,n=0,o="horizontal"){const[r,i]=e.viewBox??Fe,a=Math.min(1,Math.max(0,n)),s=Math.min(1,Math.max(0,t));return s>a?a>0||1>s?"vertical"===o?{x:0,y:i*(1-s),width:r,height:i*(s-a)}:{x:r*a,y:0,width:r*(s-a),height:i}:null:{x:0,y:0,width:0,height:0}}function Xe(e,t){const n=Ge(e,t);return{centerDx:n.offsetX+n.width/2,centerDy:n.offsetY+n.height/2,halfWidth:n.width/2,halfHeight:n.height/2,radius:Math.hypot(n.width,n.height)/2}}function Qe(e,t,n,o,r,i=e=>e){for(const a of t.parts){const t=Ze(a.d);if(!t)continue;const s=a.opacity??1,l=e.globalAlpha;1!==s&&(e.globalAlpha=l*s);const c=r?"none"===a.fill?void 0:r:Ve(a.fill,n,o);c&&(e.fillStyle=i(c),e.fill(t));const u=r?a.stroke&&"none"!==a.stroke?r:void 0:Ve(a.stroke??"none",n,o);u&&(e.strokeStyle=i(u),e.lineWidth=a.strokeWidth??1,e.lineCap=a.strokeLinecap??"butt",e.lineJoin=a.strokeLinejoin??"miter",e.stroke(t)),1!==s&&(e.globalAlpha=l)}}function Ke(e,t,n,o,r,i,a=0,s=o){if(i){const e=function(e,t,n,o,r,i=e=>e.x,a=e=>e.y,s=e=>e.r){const l=Math.max(o,r+5,12),c=t-l,u=t+l,d=n-l,h=n+l;let f=null,p=1/0;return e.visit((e,r,l,m,y)=>{if(r>u||c>m||l>h||d>y)return!0;if(!e.length){let r=e;do{const e=r.data,l=i(e)-t,c=a(e)-n,u=Math.sqrt(l*l+c*c);He(s(e),o)>=u&&p>u&&(f=e,p=u),r=r.next}while(r)}return!1}),f?{node:f,distance:p}:null}(i,t,n,o,a);if(e)return e}else{let r=null,i=o;for(const a of e){if("point"!==a.type)continue;const e=a.x-t,s=a.y-n,l=Math.sqrt(e*e+s*s);He(a.r,o)>=l&&i>l&&(r=a,i=l)}if(r)return{node:r,distance:i}}let l=null,c=o;for(const r of e){if("glyph"!==r.type)continue;if(null==r.datum)continue;const e=Xe(r.glyph,r.size),i=r.x+e.centerDx-t,a=r.y+e.centerDy-n,s=Math.sqrt(i*i+a*a);He(e.radius,o)>=s&&c>s&&(l=r,c=s)}if(l)return{node:l,distance:c};for(let o=e.length-1;o>=0;o--){const i=e[o];if("geoarea"!==i.type)continue;const a=i;if(!1===a.interactive)continue;const[[s,l],[c,u]]=a.bounds;if(!(s>t||t>c||l>n||n>u)&&(a._cachedPath2D||(a._cachedPath2D=new Path2D(a.pathData)),r.isPointInPath(a._cachedPath2D,t,n)))return{node:a,distance:0}}let u=null,d=s;for(const o of e){if("line"!==o.type)continue;const e=o,{path:r}=e,i=Math.max((e.style.strokeWidth||2)+4,5,s);for(let o=0;r.length-1>o;o++){const[a,s]=r[o],[l,c]=r[o+1],h=Je(t,n,a,s,l,c);i>=h&&d>h&&(u=e,d=h)}}return u?{node:u,distance:d}:null}function Je(e,t,n,o,r,i){const a=r-n,s=i-o,l=a*a+s*s;if(0===l)return Math.sqrt((e-n)**2+(t-o)**2);let c=((e-n)*a+(t-o)*s)/l;return c=Math.max(0,Math.min(1,c)),Math.sqrt((e-(n+c*a))**2+(t-(o+c*s))**2)}import*as et from"react";import{useCallback as tt,useEffect as nt,useLayoutEffect as ot,useMemo as rt,useRef as it}from"react";import{createContext as at,useCallback as st,useContext as lt,useMemo as ct,useRef as ut,useSyncExternalStore as dt}from"react";import{jsx as ht}from"react/jsx-runtime";function ft(e){let t=null;const n=()=>(t||(t=at(null)),t),o=pt(e);return[function({children:t,initialState:o}){const r=ut(o),i=ct(()=>pt(e,r.current),[]),a=n();return ht(a.Provider,{value:i,children:t})},(e,t)=>{const r=n(),i=lt(r)??o,a=ut(e);a.current=e;const s=ut({hasValue:!1,value:void 0}),l=st(()=>{const e=a.current(i.getState()),n=s.current;return n.hasValue&&t&&t(n.value,e)?n.value:(s.current={hasValue:!0,value:e},e)},[i,t]),c=st(()=>a.current(i.getState()),[i]);return dt(i.subscribe,l,c)}]}function pt(e,t){const n=new Set;let o={...e(function(e){const t=e(o);if(function(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}(t)){o={...o,...t};for(const e of n)e()}}),...t??{}};return{getState:()=>o,subscribe:function(e){return n.add(e),()=>{n.delete(e)}}}}function mt(e){if(!e?.colors)return;const t=e.colors;return{primary:t.primary,secondary:t.secondary||t.primary,surface:t.surface||t.background,success:t.success,danger:t.danger,warning:t.warning,error:t.error,info:t.info,text:t.text,textSecondary:t.textSecondary,border:t.border,grid:t.grid}}function yt(e){if(!e.accessibility)return e;let t=e;if(e.accessibility.colorBlindSafe&&(t={...t,colors:{...t.colors,categorical:gt}}),e.accessibility.highContrast){const e="dark"===t.mode;t={...t,colors:{...t.colors,text:e?"#ffffff":"#000000",textSecondary:e?"#cccccc":"#333333",grid:e?"#666666":"#999999",border:e?"#888888":"#000000"}}}return t}var gt=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],bt={mode:"light",colors:{primary:"#00a2ce",secondary:"#6c757d",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",diverging:"RdBu",background:"transparent",surface:"#ffffff",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc",selection:"#00a2ce",selectionOpacity:.15,success:"#2ca02c",danger:"#d62728",warning:"#f0ad4e",error:"#b4181b",info:"#00a2ce"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:12}},vt={mode:"dark",colors:{primary:"#4fc3f7",secondary:"#90a4ae",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",diverging:"RdBu",background:"#1a1a2e",surface:"#252540",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555",selection:"#4fc3f7",selectionOpacity:.15,success:"#81c784",danger:"#ef5350",warning:"#ffb74d",error:"#d84848",info:"#4fc3f7"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:12}},xt={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:gt,sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1,success:"#006400",danger:"#cc0000",warning:"#b15a00",error:"#8b0000",info:"#0000cc"},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"};function wt(e,t){if("light"===t)return bt;if("dark"===t)return vt;if("high-contrast"===t)return xt;if("string"==typeof t)return void 0!==console&&console.warn(`[ThemeStore] Unknown theme preset "${t}". Keeping current theme.`),e;if(t.mode&&"auto"!==t.mode){const e="dark"===t.mode?vt:bt;return yt({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}}})}return yt({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}}})}var[kt,St]=ft(e=>({theme:bt,setTheme(t){e(e=>({theme:wt(e.theme,t)}))}}));import{useState as At,useEffect as Ct}from"react";import{useRef as Mt,useState as Rt,useEffect as Lt}from"react";var jt=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,Pt=new WeakMap,It=0,Tt=!1,Dt=null,zt=null;function Ot(e,t){if(!t)return t;const n=jt.exec(t);if(!n)return t;const o=e.canvas;if(!o)return n[2]?.trim()||t;!function(){if(Tt)return;if("undefined"==typeof window||"undefined"==typeof document)return;Tt=!0;const e=()=>{It++};if("undefined"!=typeof MutationObserver&&document.documentElement&&new MutationObserver(e).observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]}),"function"==typeof window.matchMedia)try{Dt=window.matchMedia("(prefers-color-scheme: dark)"),zt=e,"function"==typeof Dt.addEventListener?Dt.addEventListener("change",zt):"function"==typeof Dt.addListener&&Dt.addListener(zt)}catch{}}();let r=Pt.get(o);r&&r.version===It||(r={version:It,map:new Map},Pt.set(o,r));const i=r.map.get(t);if(void 0!==i)return i;const a=getComputedStyle(o).getPropertyValue(n[1]).trim()||n[2]?.trim()||t;return r.map.set(t,a),a}var Nt=()=>"undefined"!=typeof performance?performance.now():Date.now();function Bt(e,t){const n=e();return Number.isFinite(n)?n:t}var Et=class{constructor(e={}){this.randomSource=Math.random,this.subscribers=new Set,this.now=()=>this.advance(),this.random=()=>this.randomSource(),this.clock=e.clock??Nt,this.lastWallTime=Bt(this.clock,0),this.logicalTime=this.lastWallTime,this.pausedValue=!0===e.paused,this.visibleValue=!1!==e.visible,this.setRandomSource(e.random,e.seed)}get isActive(){return!this.pausedValue&&this.visibleValue}get paused(){return this.pausedValue}get seed(){return this.seedValue}get visible(){return this.visibleValue}configure(e){this.setClock(e.clock),this.setRandomSource(e.random,e.seed)}setPaused(e){this.pausedValue!==e&&(this.advance(),this.pausedValue=e,this.emit())}setVisible(e){this.visibleValue!==e&&(this.advance(),this.visibleValue=e,this.emit())}snapshot(){return{now:this.now(),paused:this.pausedValue,seed:this.seedValue,visible:this.visibleValue}}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}advance(){const e=Bt(this.clock,this.lastWallTime),t=Math.max(0,e-this.lastWallTime);return this.lastWallTime=e,this.isActive&&(this.logicalTime+=t),this.logicalTime}emit(){for(const e of this.subscribers)e()}setClock(e){const t=e??Nt;t!==this.clock&&(this.advance(),this.clock=t,this.lastWallTime=Bt(t,this.lastWallTime))}setRandomSource(e,t){const n=function(e){return"number"==typeof e&&Number.isFinite(e)?Math.trunc(e):void 0}(t);e===this.randomInput&&n===this.seedValue||(this.randomInput=e,this.seedValue=n,this.randomSource=e??(void 0===n?Math.random:function(e){let t=e>>>0;return()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}(n)))}},Wt="undefined"==typeof window?nt:ot,_t={requestAnimationFrame:e=>("undefined"==typeof window?globalThis:window).requestAnimationFrame(e),cancelAnimationFrame:e=>("undefined"==typeof window?globalThis:window).cancelAnimationFrame(e)};function Ht(e,t,n){return"function"==typeof e?e({size:t,margin:n}):e}function Ft(e){const t=function(){const[e,t]=At(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return Ct(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");return t(e.matches),function(e,t){if("function"==typeof e.addEventListener)return e.addEventListener("change",t),()=>e.removeEventListener("change",t);const n=e;return n.addListener(t),()=>n.removeListener(t)}(e,e=>t(e.matches))},[]),e}(),n=it(t);n.current=t;const[o,r]=function(e,t,n){const o=Mt(null),[r,i]=Rt(null);return Lt(()=>{if(!t&&!n)return;const e=o.current;if(!e)return;const r=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;i(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return r.observe(e),()=>r.disconnect()},[t,n]),[o,[t&&r?r.w:e[0],n&&r?r.h:e[1]]]}(e.sizeProp,e.responsiveWidth,e.responsiveHeight),i=!!e.title,a=!!e.legend&&"top"===e.legendPosition,s=rt(()=>function(e,t,n=!1){const o=n?t?58:34:t?36:0;return o>e.top?{...e,top:o}:e}({...e.marginDefault,...e.userMargin},i,a),[e.marginDefault,e.userMargin,i,a]),l=r[0]-s.left-s.right,c=r[1]-s.top-s.bottom,u=Ht(e.foregroundGraphics,r,s),d=Ht(e.backgroundGraphics,r,s),h=St(e=>e.theme),{transition:f,introEnabled:p}=function(e,t){if(!1===e)return{transition:void 0,introEnabled:!1};const n="undefined"!=typeof window&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;return{transition:e?!0===e?{duration:300}:{duration:e.duration??300,easing:"linear"===e.easing?"linear":"ease-out"}:t,introEnabled:!(n||!e||!0!==e&&!1===e.intro)}}(e.animate,e.transitionProp),m="semiotic-table-"+et.useId(),y=it(null);if(!y.current){const t=!e.suspendWhenHidden||"undefined"==typeof document||!document.hidden;y.current=new Et({clock:e.clock,random:e.random,seed:e.seed,paused:e.paused,visible:t})}const g=y.current;g.configure({clock:e.clock,random:e.random,seed:e.seed});const b=it(null),v=it(e.frameScheduler??_t);v.current=e.frameScheduler??_t;const x=it(null),w=it(!1),k=it(()=>{}),S=tt(()=>{if(null!==b.current||w.current)return;const e=v.current;let t=!1,n=!1;const o=e.requestAnimationFrame(()=>{t=!0;const e=!n;e&&(w.current=!0),b.current=null,x.current=null;try{k.current()}finally{e&&(w.current=!1)}});n=!0,t||(b.current=o,x.current=e)},[]),A=tt(()=>{null!==b.current&&((x.current??v.current).cancelAnimationFrame(b.current),b.current=null,x.current=null)},[]);Wt(()=>{g.setPaused(!0===e.paused)},[g,e.paused]),nt(()=>{if(!e.suspendWhenHidden||"undefined"==typeof document)return void g.setVisible(!0);const t=()=>g.setVisible(!document.hidden);return t(),document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[g,e.suspendWhenHidden]),nt(()=>()=>{A()},[A]);const C=it(()=>{}),M=it(()=>{}),R=it(null),L=it(null),j=it(null),P=tt(()=>{const e=R.current;R.current=null,e&&C.current(e)},[]),I=tt(e=>{if(R.current={clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType},null===L.current){const e=v.current;let t=!1;const n=e.requestAnimationFrame(()=>{t=!0,L.current=null,j.current=null,P()});t||(L.current=n,j.current=e)}},[P]),T=tt(()=>{R.current=null,null!==L.current&&((j.current??v.current).cancelAnimationFrame(L.current),L.current=null,j.current=null),M.current()},[]);nt(()=>()=>{R.current=null,null!==L.current&&((j.current??v.current).cancelAnimationFrame(L.current),L.current=null,j.current=null)},[]);const D=e.themeDirtyRef;return Wt(()=>{D&&(It++,D.current=!0,S())},[h,S,D]),{reducedMotion:t,reducedMotionRef:n,responsiveRef:o,size:r,margin:s,adjustedWidth:l,adjustedHeight:c,resolvedForeground:u,resolvedBackground:d,currentTheme:h,transition:f,introEnabled:p,tableId:m,frameRuntime:g,rafRef:b,renderFnRef:k,scheduleRender:S,cancelRender:A,hoverHandlerRef:C,hoverLeaveRef:M,onPointerMove:I,onPointerLeave:T}}import{useEffect as $t,useRef as Gt}from"react";import{useEffect as qt,useRef as Vt}from"react";var Ut={fresh:1,aging:.7,stale:.45,expired:.25},Zt={alpha:1,band:"fresh",isStale:!1};import{jsx as Yt}from"react/jsx-runtime";function Xt({isStale:e,position:t}){return Yt("div",{className:"stream-staleness-badge",style:{position:"absolute",..."top-left"===t?{top:4,left:4}:"bottom-left"===t?{bottom:4,left:4}:"bottom-right"===t?{bottom:4,right:4}:{top:4,right:4},padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",zIndex:3,background:e?"#dc3545":"#28a745",color:"white"},children:e?"STALE":"LIVE"})}import*as Qt from"react";var[Kt,Jt]=ft(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 en(e,t={}){const n=function(e){const t=e.provenance,n=e.id??e.stableId??t?.stableId;return null==n||""===n?void 0:n+""}(e);return{"data-semiotic-annotation-widget":"",...n?{"data-semiotic-annotation-id":n}:{},onClickCapture(o){const r=function(e){const t=e.nativeEvent;return"touch"===t.pointerType?"touch":0===t.detail?"keyboard":"pointer"}(o);t.onAnnotationActivate?.({annotation:e,annotationId:n,chartId:t.chartId,inputType:r}),n&&t.onObservation&&t.onObservation({type:"annotation-activate",annotationId:n,inputType:r,timestamp:Date.now(),chartType:t.chartType??"unknown",chartId:t.chartId})}}}import{useMemo as tn,useRef as nn}from"react";import*as on from"react";import{jsx as rn,jsxs as an}from"react/jsx-runtime";function sn(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 ln(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 cn(e,t,n,o){if(!e)return rn("g",{className:"annotation-note"});const{label:r,title:i,orientation:a,align:s,wrap:l=120,noWrap:c}=e;if(!r&&!i)return rn("g",{className:"annotation-note"});let u=a;u||(u=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let d=s;d&&"dynamic"!==d||(d="topBottom"===u?0>t?"right":"left":0>n?"bottom":"top");let h="start";"topBottom"===u?"right"===d?h="end":"middle"===d&&(h="middle"):h=0>t?"end":"start";const f=16,p=i?c?[i]:sn(i,l):[],m=r?c?[r]:sn(r,l):[],y="leftRight"===u?"end"===h?-4:4:0;let g=0;const b=[],v=o||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";e.useHTML||e.html?b.push(rn("foreignObject",{className:"annotation-note-html",x:"end"===h?y-l:"middle"===h?y-l/2:y,y:-16,width:l,height:Math.max(f,(p.length+m.length)*f+(i&&r?2:0))+f,style:{overflow:"visible"},children:an("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{color:v,fontSize:"12px",lineHeight:"16px",overflow:"visible",textAlign:"end"===h?"right":"middle"===h?"center":"left",whiteSpace:c?"nowrap":"normal",wordBreak:"break-word"},children:[i&&rn("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:i}),r&&rn("div",{className:"annotation-note-label",children:r})]})},"annotation-note-html")):(p.length>0&&(b.push(rn("text",{className:"annotation-note-title",fill:v,textAnchor:h,fontWeight:"bold",children:p.map((e,t)=>rn("tspan",{x:y,dy:0===t?0:f,children:e},t))},"annotation-note-title")),g=p.length*f),m.length>0&&b.push(rn("text",{className:"annotation-note-label",fill:v,textAnchor:h,y:g,children:m.map((e,t)=>rn("tspan",{x:y,dy:0===t?0:f,children:e},t))},"annotation-note-label")));let x=null;if((i||r)&&(0!==t||0!==n))if("topBottom"===u){const e=Math.min(l,120);let t=0,n=e;"end"===h?(t=-e,n=0):"middle"===h&&(t=-e/2,n=e/2),x=rn("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:o||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(p.length+m.length)*f+(m.length>0?f:0);let t=0,n=e;"bottom"===d?(t=-e,n=0):"middle"===d&&(t=-e/2,n=e/2),x=rn("line",{className:"note-line",x1:0,x2:0,y1:t,y2:n,stroke:o||"var(--semiotic-text-secondary, currentColor)"})}const w=Math.max(0,p.length+m.length-1)*f;let k=0;return"topBottom"===u?k=0>n?-(w+2):18:"leftRight"===u&&(k="middle"===d?-(w+f+(m.length>0&&p.length>0?2:0))/2+8:"bottom"===d||0>n?-(w+2):18),an("g",{className:"annotation-note",transform:`translate(${t},${n})`,children:[rn("g",{className:"annotation-note-content",transform:0!==k?`translate(0,${k})`:void 0,children:b}),x]})}function un(e,t,n,o,r){const i=[];switch(e){case"callout-circle":{const e=(t?.radius||0)+(t?.radiusPadding||0);e>0&&i.push(rn("circle",{r:e,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const e=t?.width||0,o=t?.height||0;(e>0||o>0)&&i.push(rn("rect",{width:e,height:o,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":t?.custom&&i.push(...Array.isArray(t.custom)?t.custom:[t.custom]);break;case"xy-threshold":{const e=o||0,a=r||0;if(void 0!==t?.x){const o=(t.x||0)-e;i.push(rn("line",{x1:o,y1:(t.y1||0)-a,x2:o,y2:(t.y2||0)-a,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==t?.y){const o=(t.y||0)-a;i.push(rn("line",{x1:(t.x1||0)-e,y1:o,x2:(t.x2||0)-e,y2:o,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==t?.x1||void 0!==t?.x2?i.push(rn("line",{x1:(t.x1||0)-e,y1:0,x2:(t.x2||0)-e,y2:0,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===t?.y1&&void 0===t?.y2||i.push(rn("line",{x1:0,y1:(t.y1||0)-a,x2:0,y2:(t.y2||0)-a,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const e=t?.type||"curly",o=t?.width??t?.height;void 0!==o&&i.push(rn("path",{d:ln(e,o,t?.depth||30,void 0===t?.width),fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return rn("g",{className:"annotation-subject",children:i})}function dn(e,t,n,o,r,i){const a=[];let s=0,l=0;if("callout-circle"!==r&&"label"!==r||!i?.radius){if("callout-rect"===r&&i){const n=i.width||0,o=i.height||0;if(n>0||o>0){const r=n/2,i=o/2,a=e-r,c=t-i;if(0!==a||0!==c){const e=Math.abs(a),t=Math.abs(c),u=n/2,d=o/2,h=e*d>t*u?u/e:d/t;s=r+a*h,l=i+c*h}}}else if("bracket"===r&&i){const e=i.width,t=i.height,n=i.depth||30;void 0!==e?(s=e/2,l=n):void 0!==t&&(s=n,l=t/2)}}else{const n=(i.radius||0)+(i.radiusPadding||0);if(n>0&&(0!==e||0!==t)){const o=Math.atan2(t,e);s=Math.cos(o)*n,l=Math.sin(o)*n}}const c=Math.sqrt((e-s)**2+(t-l)**2);if(c>.5){const r=o||"var(--semiotic-text-secondary, currentColor)",i="curve"===n?.type;let u=Math.atan2(t-l,e-s);if(i){const o=(s+e)/2,i=(l+t)/2,d=-(t-l)/c,h=(e-s)/c,f=(n?.curve??.25)*c,p=o+d*f,m=i+h*f;a.push(rn("path",{className:"connector-curve",d:`M${s},${l}Q${p},${m} ${e},${t}`,fill:"none",stroke:r},"connector-line")),u=Math.atan2(m-l,p-s)}else a.push(rn("line",{x1:s,y1:l,x2:e,y2:t,stroke:r},"connector-line"));if("arrow"===n?.end){const e=10,t=16/180*Math.PI;a.push(rn("path",{d:`M${s},${l}L${s+e*Math.cos(u+t)},${l+e*Math.sin(u+t)}L${s+e*Math.cos(u-t)},${l+e*Math.sin(u-t)}Z`,fill:r,stroke:"none"},"connector-arrow"))}}return rn("g",{className:"annotation-connector",children:a})}function hn(e){const{x:t=0,y:n=0,dx:o,dy:r,nx:i,ny:a,note:s,connector:l,subject:c,type:u,color:d,className:h,disable:f,opacity:p,strokeDasharray:m,events:y={},"data-testid":g}=e,b=Array.isArray(t)?t[0]??0:t,v=Array.isArray(n)?n[0]??0:n,x=new Set(Array.isArray(f)?f:[]);let w=o||0,k=r||0;null!=i&&(w=i-b),null!=a&&(k=a-v);const S="string"==typeof u?u:"label";if("bracket"===S&&c&&0===w&&0===k)if(void 0!==c.width){w=c.width/2;const e=c.depth||30;k=e+(0>e?-5:5)}else if(void 0!==c.height){const e=c.depth||30;w=e+(0>e?-5:5),k=c.height/2}return an("g",{className:("annotation "+(h||"")).trim(),transform:`translate(${b},${v})`,"data-testid":g,...null!=p&&{opacity:p},...m&&{strokeDasharray:m},...y,children:[!x.has("connector")&&dn(w,k,l,d,S,c),!x.has("subject")&&un(S,c,d,b,v),!x.has("note")&&cn(s,w,k,d)]})}function fn(e){const{noteData:t}=e,{screenCoordinates:n}=t,o="string"==typeof t.type?t.type:"label",r=t.eventListeners||t.events||{};if(t.coordinates&&n){const e=t.nx||n[0][0]+(t.dx??0),r=t.ny||n[0][1]+(t.dy??0),i=n.map((n,i)=>{const a=Object.assign({},t,{note:0===i?t.note:{label:""},x:n[0],y:n[1],nx:e,ny:r});return rn(hn,{"data-testid":"semiotic-annotation",...a,type:o},"multi-annotation-"+i)});return rn("g",{children:i})}const i=t.note||{title:"none",label:t.label},a=`${i.label}-${i.title}-${t.i}`;return rn(hn,{"data-testid":"semiotic-annotation",events:r,...t,type:o},a)}import{packEnclose as pn}from"d3-hierarchy";import{area as mn,curveLinear as yn,curveMonotoneX as gn,curveMonotoneY as bn,curveStep as vn,curveStepAfter as xn,curveStepBefore as wn,curveBasis as kn,curveCardinal as Sn,curveCatmullRom as An}from"d3-shape";function Cn(e){return Math.round(100*e)/100}function Mn(e,t=2){const n=[],o=[],r=t+1;for(let t=0;r>t;t++){let i=0;for(const[n,o]of e)null!==o&&(i+=n**t*o);n.push(i);const a=[];for(let n=0;r>n;n++){let o=0;for(const[r,i]of e)null!==i&&(o+=r**(t+n));a.push(o)}o.push(a)}o.push(n);const i=function(e,t){const n=e,o=e.length-1,r=[t];for(let e=0;o>e;e++){let t=e;for(let r=e+1;o>r;r++)Math.abs(n[e][r])>Math.abs(n[e][t])&&(t=r);for(let r=e;o+1>r;r++){const o=n[r][e];n[r][e]=n[r][t],n[r][t]=o}for(let t=e+1;o>t;t++)for(let r=o;r>=e;r--)n[r][t]-=n[r][e]*n[e][t]/n[e][e]}for(let e=o-1;e>=0;e--){let t=0;for(let i=e+1;o>i;i++)t+=n[i][e]*r[i];r[e]=(n[o][e]-t)/n[e][e]}return r}(o,r).map(Cn);return{points:e.map(([e])=>[Cn(e),Cn(i.reduce((t,n,o)=>t+n*e**o,0))]),equation:[...i].reverse()}}function Rn(e,t){const n=t.scales?.x??t.scales?.time;return n?null!=e.x?n(e.x):t.xAccessor&&null!=e[t.xAccessor]?n(e[t.xAccessor]):null:null}function Ln(e,t){const n=t.scales?.y??t.scales?.value;return n?null!=e.y?n(e.y):t.yAccessor&&null!=e[t.yAccessor]?n(e[t.yAccessor]):null:null}function jn(e){return null==e?null:e+""}function Pn(e,t,n){return t.stickyPositionCache?.set(e,n),n}function In(e,t,n){const o=e.anchor||e.lifecycle?.anchor||"fixed";if("latest"===o){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let o=n.pointNodes.length-1;o>=0;o--){const r=n.pointNodes[o];if(r.pointId===e.pointId)return Pn(t,n,{x:r.x,y:r.y})}const o=function(e){const t=e.data;if(!t||0===t.length)return null;const n=t[t.length-1],o=e.scales?.x??e.scales?.time,r=e.scales?.y??e.scales?.value;if(!o||!r)return null;const i=n[e.xAccessor||"x"],a=n[e.yAccessor||"y"];return null==i||null==a?null:{x:o(i),y:r(a)}}(n);return o?Pn(t,n,o):null}if("semantic"===o){const o=function(e,t,n){const o=function(e){return jn(e.provenance?.stableId??e.stableId)}(e);if(!o)return null;const r=n.pointNodes?.find(e=>jn(e.pointId)===o);if(r)return Pn(t,n,{x:r.x,y:r.y});const i=n.data?.find(e=>function(e){return jn(e.stableId??e.id??e.provenance?.stableId)}(e)===o);if(!i)return null;const a=Rn(i,n),s=Ln(i,n);return null==a||null==s?null:Pn(t,n,{x:a,y:s})}(e,t,n);if(o)return o}let r=null,i=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(r=t.x,i=t.y)}if(null!=r&&null!=i||(r=Rn(e,n),i=Ln(e,n)),null!=r&&null!=i)return Pn(t,n,{x:r,y:i});if("sticky"===o){const e=n.stickyPositionCache?.get(t);if(e)return e}return null}function Tn(e,t,n,o=50){return!(-o>e||e>(n.width||0)+o||-o>t||t>(n.height||0)+o)}import{jsx as Dn}from"react/jsx-runtime";var zn={secondary:0,primary:3};function On(e){return!0===e?._annotationDeferred}function Nn(e){return"blended"===e?.cohesion||"layer"===e?.cohesion?e.cohesion:null}function Bn(e){const t=e?.provenance?.confidence;return"number"==typeof t&&Number.isFinite(t)?Math.max(0,Math.min(1,t)):null}function En(e){return Math.max(.72,.95-.06*e)}import{jsx as Wn,jsxs as _n}from"react/jsx-runtime";var Hn="var(--semiotic-bg, #ffffff)";function Fn(e){const{x:t,y:n,text:o,fill:r,fontSize:i=12,fontWeight:a,fontFamily:s,textAnchor:l="start",dominantBaseline:c,background:u,className:d}=e,h=function(e){return void 0===e||!0===e||"halo"===e?{type:"halo"}:!1===e||"none"===e?null:"box"===e?{type:"box"}:{type:e.type??"halo",...e}}(u),f=e=>Wn("text",{x:t,y:n,textAnchor:l,dominantBaseline:c,fill:r,fontSize:i,fontWeight:a,fontFamily:s,className:d,...e?{stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:"stroke"}:{},children:o});if(!h)return f();if("halo"===h.type)return f({stroke:h.fill??Hn,strokeWidth:h.haloWidth??3});const p=h.padding??{x:6,y:3},m="number"==typeof p?p:p.x,y="number"==typeof p?p:p.y,g=function(e,t){return(e+"").length*t*.6}(o,i),b=i+2*y;let v,x;return v="middle"===l?t-g/2-m:"end"===l?t-g-m:t-m,x="middle"===c||"central"===c?n-b/2:"hanging"===c||"text-before-edge"===c?n-y:n-.8*i-y,_n("g",{className:d,children:[Wn("rect",{x:v,y:x,width:g+2*m,height:b,rx:h.radius??3,ry:h.radius??3,fill:h.fill??Hn,fillOpacity:h.opacity??.85,stroke:h.stroke,strokeWidth:h.strokeWidth}),f()]})}var $n=null;import{jsx as Gn,jsxs as qn}from"react/jsx-runtime";function Vn(e){return"object"==typeof e&&null!==e&&"hatch"===e.type}function Un(e){return["hatch",e.background??"transparent",e.stroke??"#000",e.lineWidth??1.5,e.spacing??6,e.angle??45,e.lineOpacity??1].join("|")}function Zn(e,t){let n=2166136261;const o=Un(t);for(let e=0;o.length>e;e++)n^=o.charCodeAt(e),n=Math.imul(n,16777619);return`${e}-hatch-${(n>>>0).toString(36)}`}var Yn=new Map;function Xn(e,t){const{background:n="transparent",stroke:o="#000",lineWidth:r=1.5,spacing:i=6,angle:a=45,lineOpacity:s=1}=e,l=Math.max(8,Math.ceil(2*i));return qn("pattern",{id:t,width:l,height:l,patternUnits:"userSpaceOnUse",patternTransform:0!==a?`rotate(${a})`:void 0,children:[n&&"transparent"!==n&&Gn("rect",{width:l,height:l,fill:n}),Gn("line",{x1:0,y1:0,x2:0,y2:l,stroke:o,strokeWidth:r,strokeOpacity:s}),Gn("line",{x1:i,y1:0,x2:i,y2:l,stroke:o,strokeWidth:r,strokeOpacity:s})]},t)}function Qn(e,t,n="#4e79a7"){if(Vn(e)){const n=Zn(t,e);return{fill:`url(#${n})`,def:Xn(e,n)}}return e&&"string"==typeof e?{fill:e}:{fill:n}}import{jsx as Kn,jsxs as Jn}from"react/jsx-runtime";var eo={linear:yn,monotoneX:gn,monotoneY:bn,step:vn,stepAfter:xn,stepBefore:wn,basis:kn,cardinal:Sn,catmullRom:An};var to=new Set(["label","callout","callout-circle","callout-rect","text","widget"]);function no(e){return!!e&&"object"==typeof e&&to.has(function(e){return"string"==typeof e?.type?e.type:""}(e))}function oo(e){return"primary"===e?.emphasis||!0===e?.defensive}function ro(e,t,n={}){return"number"==typeof n.maxAnnotations&&Number.isFinite(n.maxAnnotations)?Math.max(0,Math.floor(n.maxAnnotations)):e>0&&t>0?Math.max(1,Math.round(e*t/(n.areaPerAnnotation&&n.areaPerAnnotation>0?n.areaPerAnnotation:2e4))):1/0}function io(e){let t;const n=e?.emphasis;t="primary"===n?100:"secondary"===n?10:50;const o=e?.provenance?.confidence;switch("number"==typeof o&&Number.isFinite(o)&&(t+=15*Math.max(0,Math.min(1,o))),e?.lifecycle?.freshness){case"fresh":t+=8;break;case"aging":t+=4;break;case"stale":t+=1;break;case"expired":t-=200}return t}new Set(["label","callout","callout-circle","callout-rect"]);var ao=32,so=6,lo=4,co=8,uo=72;var ho={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function fo(e){if(!po(e))return e;const t=("string"==typeof e.mobileText?e.mobileText:void 0)??("string"==typeof e.shortText?e.shortText:void 0);return!t||"string"!=typeof e.label&&null!=e.label?e:{...e,label:t}}function po(e){return no(e)}function mo(e,t){if(!e)return[];const n=Math.max(1,Math.floor(t/7)),o=e.split(/\s+/).filter(Boolean),r=[];let i="";for(const e of o)i&&i.length+e.length+1>n?(r.push(i),i=e):i=i?`${i} ${e}`:e;return i&&r.push(i),r}function yo(e,t,n,o,r){const i=e+n,a=t+o;return Math.abs(n)>Math.abs(o)?{x:0>n?i-r.width-4:i+4,y:0>o?a-r.height:a,width:r.width,height:r.height}:{x:0>n?i-r.width:i,y:0>o?a-r.height-4:a+4,width:r.width,height:r.height}}function go(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function bo(e,t){return Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y))}function vo(e,t,n,o,r,i,a,s){const l=go(e,a);let c=.4*Math.hypot(t.dx,t.dy)+80*function(e,t,n,o){const r=Math.max(0,o-e.x),i=Math.max(0,o-e.y);return(r+Math.max(0,e.x+e.width-(t-o)))*e.height+(i+Math.max(0,e.y+e.height-(n-o)))*e.width}(l,r,i,s);for(const e of n)c+=12*bo(l,e);for(const e of o)c+=4*bo(l,e);return c}function xo(e){const{annotations:t,context:n,defaultOffset:o=ao,notePadding:r=so,markPadding:i=lo,edgePadding:a=co,preserveManualOffsets:s=!0,routeLongConnectors:l=!0,connectorThreshold:c=uo,density:u,progressiveDisclosure:d=!1,redundantCues:h=!1,responsive:f,mobile:p,cohesion:m,audience:y}=e,g=n.width||0,b=n.height||0,v="object"==typeof p?p:{},x=v.breakpoint??480,w=!!p&&x>=g,k=w&&!1!==v.preferShortText?t.map(fo):t,S=w&&!u?{maxAnnotations:v.maxAnnotations??("callout-list"===v.strategy?1:2),minVisible:v.minVisible??1}:u,A=d||w&&(!1!==v.progressiveDisclosure||"callout-list"===v.strategy),C=w&&!f?v.responsive??{minWidth:x}:f,M=w&&!m?v.cohesion:m;if(0===k.length||0>=g||0>=b)return k.slice();const R=[],L=function(e,t){return(e.pointNodes||[]).map(e=>{const n=Math.max(1,e.r||1)+t;return{x:e.x-n,y:e.y-n,width:2*n,height:2*n}})}(n,i);let j=!1;const P=k.map((e,t)=>{if(!po(e))return e;const i=function(e,t,n){if("widget"===e.type&&"number"==typeof e.px&&"number"==typeof e.py)return{x:e.px,y:e.py};const o=e.pointId??e.nodeId;if(null!=o&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===o);if(e)return{x:e.x,y:e.y}}const r=e.coordinates,i=n.scales?.geoProjection;if(Array.isArray(r)&&r.length>=2&&i){const e=r[0],t=r[1];if("number"==typeof e&&"number"==typeof t){const n=i([e,t]);if(n&&"number"==typeof n[0]&&"number"==typeof n[1])return{x:n[0],y:n[1]}}}return n.scales||"number"!=typeof e.x||"number"!=typeof e.y?In(e,t,n):{x:e.x,y:e.y}}(e,t,n);if(!i)return e;const u=function(e){if("widget"===e.type)return{width:"number"==typeof e.width?e.width:32,height:"number"==typeof e.height?e.height:32};const t="number"==typeof e.wrap?e.wrap:120,n=[...mo("string"==typeof e.title?e.title:void 0,t),...mo("string"==typeof e.label?e.label:void 0,t)],o=n.reduce((e,t)=>Math.max(e,t.length),0);return{width:Math.max(24,Math.min(t,7*o)+10),height:Math.max(18,16*n.length+6)}}(e);if(s&&("number"==typeof(d=e).dx||"number"==typeof d.dy)){const t=function(e){return"text"===e.type||"widget"===e.type?{dx:0,dy:0}:{dx:30,dy:-30}}(e);return R.push(go(yo(i.x,i.y,"number"==typeof e.dx?e.dx:t.dx,"number"==typeof e.dy?e.dy:t.dy,u),r)),e}var d;let h=null,f=1/0;for(const e of function(e){const t=1.6*e;return[{dx:e,dy:-e},{dx:-e,dy:-e},{dx:e,dy:e},{dx:-e,dy:e},{dx:e,dy:0},{dx:-e,dy:0},{dx:0,dy:-e},{dx:0,dy:e},{dx:t,dy:-t},{dx:-t,dy:-t},{dx:t,dy:t},{dx:-t,dy:t}]}(o)){const t=vo(yo(i.x,i.y,e.dx,e.dy,u),e,R,L,g,b,r,a);f>t&&(h=e,f=t)}if(!h)return e;const p=go(yo(i.x,i.y,h.dx,h.dy,u),r);R.push(p);const m=Math.hypot(h.dx,h.dy),y=l&&m>=c&&"text"!==e.type&&"widget"!==e.type?{...e.connector||{end:"arrow"},type:"curve"}:e.connector;return j=!0,{...e,dx:h.dx,dy:h.dy,...y?{connector:y}:{}}}),I=j?P:k.slice();let T=I;if(h){let e=!1;const t=I.map(t=>{const n=function(e){return"text"!==e.type||"string"!=typeof e.color||8>Math.hypot("number"==typeof e.dx?e.dx:0,"number"==typeof e.dy?e.dy:0)?e:{...e,_redundantConnector:!0}}(t);return n!==t&&(e=!0),n});T=e?t:I}{let e=!1;const t=T.map(t=>{if(!0!==t?.defensive)return t;const n=function(e){const t=e?.provenance;if(!t||"object"!=typeof t)return e;const n="string"==typeof t.source?ho[t.source]??t.source:null,o="number"==typeof t.confidence&&Number.isFinite(t.confidence)?Math.round(100*Math.max(0,Math.min(1,t.confidence)))+"%":null;if(!n&&!o)return e;if(null!=e.label&&"string"!=typeof e.label)return e;const r=[n,o].filter(Boolean).join(" · "),i="string"==typeof e.label?e.label:"";return i.includes(`(${r})`)?e:{...e,label:i?`${i} (${r})`:`(${r})`}}(t);return n!==t&&(e=!0),n});T=e?t:T}const D=new Set;if(S){const e="object"==typeof S?S:{},t=function(e){if(!e)return 1;const t=function(e){const t=e?.familiarity;if(!t)return 3;const n=Object.values(t).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===n.length?3:n.reduce((e,t)=>e+t,0)/n.length}(e);return t>2?4>t?1:.6:1.5}(y),n=1===t?e:{...e,maxAnnotations:Math.max(0,Math.round((e.maxAnnotations??ro(g,b,e))*t))},{deferred:o}=function(e){const{annotations:t,width:n,height:o}=e,r=Math.max(0,e.minVisible??1),i=ro(n,o,e),a=t.map((e,t)=>{return{annotation:e,index:t,note:(n=e,no(n))};var n}),s=a.filter(e=>e.note);if(0===s.length||i>=s.length)return{visible:t.slice(),deferred:[],budget:i};const l=s.filter(e=>oo(e.annotation)),c=s.filter(e=>!oo(e.annotation)).sort((e,t)=>io(t.annotation)-io(e.annotation)||e.index-t.index),u=Math.min(c.length,Math.max(Math.max(0,i-l.length),Math.max(0,r-l.length))),d=new Set([...l.map(e=>e.index),...c.slice(0,u).map(e=>e.index)]),h=[],f=[];for(const{annotation:e,index:t,note:n}of a)!n||d.has(t)?h.push(e):f.push(e);return{visible:h,deferred:f,budget:i}}({annotations:T,width:g,height:b,...n});for(const e of o)D.add(e)}if(C&&("object"==typeof C&&"number"==typeof C.minWidth?C.minWidth:480)>=g)for(const e of T)po(e)&&"secondary"===e.emphasis&&D.add(e);if(D.size>0)for(const e of T)!0===e?.defensive&&D.delete(e);let z;return z=0===D.size?T:A?T.map(e=>D.has(e)?{...e,_annotationDeferred:!0}:e):T.filter(e=>!D.has(e)),M?function(e,t){let n=!1;const o=e.map(e=>po(e)?"blended"===e.cohesion||"layer"===e.cohesion?e:(n=!0,{...e,cohesion:t}):e);return n?o:e}(z,M):z}import*as wo from"react";import{jsx as ko,jsxs as So}from"react/jsx-runtime";var Ao={fill:(e,t)=>ko("rect",{style:e,width:t,height:t}),line:(e,t)=>ko("line",{style:e,x1:0,y1:0,x2:t,y2:t})};function Co(e,t,n,o,r){let i;return i="function"==typeof n?n(e):(0,Ao[n])(o(e,t),r),i}function Mo({swatchSize:e}){return ko("path",{d:`M${.25*e},${.55*e} L${.45*e},${.75*e} L${.8*e},${.3*e}`,fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function Ro(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}var Lo=(e,t,n,o,r,i,a,s,l,c,u)=>{const{type:d="fill",styleFn:h,items:f}=e,p=[];let m=0;const y=!(!t&&!n),g="isolate"===c||void 0===c&&null!=r,{swatchSize:b,labelGap:v,rowHeight:x}=u;return f.forEach((e,c)=>{const u=Co(e,c,d,h,b),w=Ro(e,o,r),k=r&&r.size>0&&r.has(e.label);p.push(So("g",{transform:`translate(0,${m})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:y?s===i&&c===a?0:-1:void 0,role:y?"option":void 0,"aria-selected":y&&g?k||!1:void 0,"aria-current":y&&!g&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:y?n=>{if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowDown"===n.key||"ArrowUp"===n.key){n.preventDefault();const e=(c+("ArrowDown"===n.key?1:-1)+f.length)%f.length;l(s,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:y?t=>{l(s,c),n&&n(e);const o=t.currentTarget.querySelector(".semiotic-legend-focus-ring");o&&o.setAttribute("visibility","visible")}:void 0,onBlur:y?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:y?"pointer":"default",opacity:w,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[y&&ko("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:b+v+2+7*e.label.length,height:b+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),u,k&&ko(Mo,{swatchSize:b}),ko("text",{y:b/2,x:b+v,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+c)),m+=x}),p};function jo({config:e,orientation:t="vertical",width:n=100}){const{colorFn:o,domain:r,label:i,format:a}=e,s=a||(e=>Math.round(100*e)/100+""),l="grad-legend-"+wo.useId();if("horizontal"===t){const e=12,t=Math.min(n,200),a=Math.max(0,(n-t)/2),c=[];for(let e=0;64>=e;e++){const t=e/64;c.push(ko("stop",{offset:100*t+"%",stopColor:o(r[0]+t*(r[1]-r[0]))},e))}return So("g",{"aria-label":i||"Gradient legend",children:[ko("defs",{children:ko("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:c})}),i&&ko("text",{x:a+t/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:i}),ko("rect",{x:a,y:0,width:t,height:e,fill:`url(#${l})`,rx:2}),ko("text",{x:a,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:s(r[0])}),ko("text",{x:a+t,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:s(r[1])})]})}const c=[];for(let e=0;64>=e;e++){const t=e/64;c.push(ko("stop",{offset:100*t+"%",stopColor:o(r[1]-t*(r[1]-r[0]))},e))}return So("g",{"aria-label":i||"Gradient legend",children:[i&&ko("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:i}),ko("defs",{children:ko("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:c})}),ko("rect",{x:0,y:0,width:14,height:100,fill:`url(#${l})`,rx:2}),ko("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:s(r[1])}),ko("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:s(r[0])})]})}function Po(e){const{legendGroups:t,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,legendInteraction:a,title:s="Legend",width:l=100,height:c=20,orientation:u="vertical",legendLayout:d}=e,h=function(e){const t=Math.max(1,e?.swatchSize??16),n=Math.max(t,e?.rowHeight??22);return{swatchSize:t,labelGap:Math.max(0,e?.labelGap??6),itemGap:Math.max(0,e?.itemGap??10),rowHeight:n,align:"left"===e?.align?"start":"right"===e?.align?"end":e?.align??"start",maxWidth:e?.maxWidth}}(d),[f,p]=wo.useState(0),[m,y]=wo.useState(0),g=wo.useCallback((e,t)=>{p(e),y(t)},[]),b="vertical"===u?(({legendGroups:e,width:t,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,focusedGroupIndex:a,focusedItemIndex:s,onFocusedIndexChange:l,legendInteraction:c,metrics:u})=>{let d=24;const h=[];return e.forEach((e,f)=>{d+=5,h.push(ko("line",{stroke:"gray",x1:0,y1:d,x2:t,y2:d},"legend-top-line legend-symbol-"+f)),d+=8,e.label&&(d+=16,h.push(ko("text",{y:d,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label},"legend-text-"+f)),d+=8),h.push(ko("g",{className:"legend-item",transform:`translate(0,${d})`,children:Lo(e,n,o,r,i,a,s,f,l,c,u)},"legend-group-"+f)),d+=e.items.length*u.rowHeight+8}),h})({legendGroups:t||[],width:l,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,focusedGroupIndex:f,focusedItemIndex:m,onFocusedIndexChange:g,legendInteraction:a,metrics:h}):(({legendGroups:e,height:t,width:n,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:a,focusedGroupIndex:s,focusedItemIndex:l,onFocusedIndexChange:c,legendInteraction:u,metrics:d})=>{let h=0;const f=[];e.forEach((e,t)=>{let p=0;e.label&&(p+=16);const m=((e,t,n,o,r,i,a,s,l,c,u,d)=>{const{type:h="fill",styleFn:f,items:p}=e,m=[],{swatchSize:y,labelGap:g,itemGap:b,rowHeight:v,align:x}=u,w=!(!t&&!n),k="isolate"===c||void 0===c&&null!=r,S=p.map(e=>y+g+7*e.label.length),A=[];let C=0,M=0;S.forEach((e,t)=>{const n=0===M?e:M+b+e;d&&d>0&&M>0&&n>d?(A.push({start:C,end:t,width:M}),C=t,M=e):M=n}),p.length>0&&A.push({start:C,end:p.length,width:M}),A.forEach((e,c)=>{let u="center"===x?Math.max(0,((d??e.width)-e.width)/2):"end"===x?Math.max(0,(d??e.width)-e.width):0;for(let d=e.start;e.end>d;d++){const e=p[d],x=Co(e,d,h,f,y),A=Ro(e,o,r),C=r&&r.size>0&&r.has(e.label);m.push(So("g",{transform:`translate(${u},${c*v})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:w?s===i&&d===a?0:-1:void 0,role:w?"option":void 0,"aria-selected":w&&k?C||!1:void 0,"aria-current":w&&!k&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:w?n=>{if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowRight"===n.key||"ArrowLeft"===n.key){n.preventDefault();const e=(d+("ArrowRight"===n.key?1:-1)+p.length)%p.length;l(s,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:w?t=>{l(s,d),n&&n(e);const o=t.currentTarget.querySelector(".semiotic-legend-focus-ring");o&&o.setAttribute("visibility","visible")}:void 0,onBlur:w?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:w?"pointer":"default",opacity:A,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[w&&ko("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:y+g+2+7*e.label.length,height:y+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),x,C&&ko(Mo,{swatchSize:y}),ko("text",{y:y/2,x:y+g,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+d)),u+=S[d]+b}});const R=Math.max(0,...A.map(e=>e.width)),L=A.length;return{items:m,offset:R,totalRows:L,totalHeight:L*v}})(e,o,r,i,a,s,l,t,c,u,d,d.maxWidth??n);p+=m.offset+5,f.push({label:e.label,...m,offset:p,totalRows:m.totalRows,totalHeight:m.totalHeight}),h+=p+12});const p=d.maxWidth??n;let m=h>p?0:"center"===d.align?Math.max(0,(p-h)/2):"end"===d.align?Math.max(0,p-h):0;const y=[];return f.forEach((n,o)=>{const r=e[o];r.label&&(y.push(ko("text",{transform:`translate(${m},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:r.label},"legend-text-"+o)),m+=16),y.push(ko("g",{className:"legend-item",transform:`translate(${m},0)`,children:n.items},"legend-group-"+o)),m+=n.offset+5,e[o+1]&&y.push(ko("line",{stroke:"gray",x1:m,y1:-8,x2:m,y2:(n.totalHeight||t)+0+8},"legend-top-line legend-symbol-"+o)),m+=12}),ko("g",{children:y})})({legendGroups:t||[],title:s,height:c,width:l,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,focusedGroupIndex:f,focusedItemIndex:m,onFocusedIndexChange:g,legendInteraction:a,metrics:h}),v=!(!n&&!o);return So("g",{role:v?"listbox":void 0,"aria-multiselectable":!(!v||"isolate"!==a&&(void 0!==a||null==i))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==s&&""!==s&&"vertical"===u&&ko("text",{className:"legend-title",y:16,x:l/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:s}),b]})}function Io(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}import{jsx as To}from"react/jsx-runtime";function Do(e){const{legend:t,totalWidth:n,totalHeight:o,margin:r,legendPosition:i="right",legendLayout:a,title:s,legendHoverBehavior:l,legendClickBehavior:c,legendHighlightedCategory:u,legendIsolatedCategories:d,legendInteraction:h}=e;if(!t)return null;const f="top"===i||"bottom"===i,p=!!s,m=Math.max(0,n-r.left-r.right),y=Math.max(1,f?a?.maxWidth??m:100);let g,b;return"left"===i?(g=Math.max(4,r.left-y-10),b=r.top):"top"===i?(g=r.left,b=p?32:8):"bottom"===i?(g=r.left,b=o-r.bottom+38):(g=n-r.right+10,b=r.top),To("g",{transform:`translate(${g}, ${b})`,children:(v=t,"object"==typeof v&&null!==v&&"gradient"in v?To(jo,{config:t.gradient,orientation:f?"horizontal":"vertical",width:y}):Io(t)?To(Po,{legendGroups:t.legendGroups,title:"",width:y,orientation:f?"horizontal":"vertical",legendLayout:a,customHoverBehavior:l,customClickBehavior:c,highlightedCategory:u,isolatedCategories:d,legendInteraction:h}):t)});var v}import{jsx as zo,jsxs as Oo}from"react/jsx-runtime";function No(e){const{width:t,height:n,totalWidth:o,totalHeight:r,margin:i,showAxes:a,title:s,legend:l,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h,legendPosition:f,legendLayout:p,foregroundGraphics:m,annotations:y,onAnnotationActivate:g,onObservation:b,chartId:v,chartType:x,autoPlaceAnnotations:w,pointNodes:k}=e,S=function(e){const t=Jt(e=>e.pushObservation),n=Qt.useCallback(n=>{e.onObservation?.(n),t?.(n)},[e,t]);return Qt.useMemo(()=>({...e,onObservation:n}),[n,e])}({onAnnotationActivate:g,onObservation:b,chartId:v,chartType:x}),A=nn([y?.length??0,new Map]),C=y?.length??0;A.current[0]!==C&&(A.current=[C,new Map]);const M=tn(()=>{if(!y||0===y.length)return null;const e={scales:null,timeAxis:"x",width:t,height:n,frameType:"xy",pointNodes:k,stickyPositionCache:A.current[1]};return function(e,t,n,o){const r=[];return e.forEach((e,i)=>{let a;if(n){const r=n(e,i,o);a=null!=r?r:t(e,i,o)}else a=t(e,i,o);a&&r.push({node:a,annotation:e})}),function(e){const t=e.map((e,t)=>{return{p:e,i:t,emphasis:(n=e.annotation,"primary"===n?.emphasis||"secondary"===n?.emphasis?n.emphasis:null),confidence:Bn(e.annotation),readingOrder:null,rank:1};var n}),n=t.some(e=>null!=e.emphasis||null!=e.confidence),o=e.some(e=>On(e.annotation)),r=e.some(e=>null!=Nn(e.annotation)),i=e.some(e=>"layer"===Nn(e.annotation));if(!n&&!o&&!r)return e.map(e=>e.node);const a=t.filter(e=>null==e.emphasis&&null!=e.confidence).slice().sort((e,t)=>(t.confidence??0)-(e.confidence??0)||e.i-t.i);a.forEach((e,t)=>{e.readingOrder=t,e.rank=2-t/Math.max(1,a.length)});for(const e of t)e.emphasis&&(e.rank=zn[e.emphasis]);const s=t.sort((e,t)=>e.rank-t.rank||e.i-t.i).map(e=>{const{p:t,i:n,emphasis:o,readingOrder:r}=e,i=On(t.annotation);let a=t.node;if("primary"===o||"secondary"===o||null!=r){const e=null==o&&null!=r;a=Dn("g",{className:e?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+o,..."secondary"===o?{opacity:.6,fontSize:"0.88em"}:{},...e?{opacity:En(r),"data-annotation-reading-order":r}:{},children:t.node},"annotation-emphasis-"+n)}const s=Nn(t.annotation);return s&&(a=Dn("g",{className:"annotation-cohesion--"+s,children:a},"annotation-cohesion-"+n)),i&&(a=Dn("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:a},"annotation-deferred-"+n)),a});return o&&s.unshift(Dn("style",{children:".annotation-deferred{opacity:0;pointer-events:none;transition:opacity .12s ease}.stream-xy-frame:hover .annotation-deferred,.stream-ordinal-frame:hover .annotation-deferred,.stream-network-frame:hover .annotation-deferred,.stream-geo-frame:hover .annotation-deferred,.stream-xy-frame:focus-within .annotation-deferred,.stream-ordinal-frame:focus-within .annotation-deferred,.stream-network-frame:focus-within .annotation-deferred,.stream-geo-frame:focus-within .annotation-deferred{opacity:1;pointer-events:auto}@media (prefers-reduced-motion:reduce){.annotation-deferred{transition:none}}"},"annotation-disclosure-style")),i&&s.unshift(Dn("style",{children:".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}"},"annotation-cohesion-style")),s}(r)}(w?xo({annotations:y,context:e,..."object"==typeof w?w:{}}):y,function(e,t={}){return function(e,n,o){switch(e.type){case"label":case"callout":case"callout-circle":case"callout-rect":{const t=In(e,n,o);if(!t)return null;const{x:r,y:i}=t;if(!Tn(r,i,o))return null;const a="callout"===e.type?"callout-circle":e.type,s="callout-circle"===a?{radius:e.radius??12,radiusPadding:e.radiusPadding}:"callout-rect"===a?{width:e.width,height:e.height}:void 0;return Kn(fn,{noteData:{x:r,y:i,dx:e.dx??30,dy:e.dy??-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:a,...s?{subject:s}:{},connector:e.connector||{end:"arrow"},color:e.color,disable:e.disable,opacity:e.opacity,strokeDasharray:e.strokeDasharray,className:e.className}},"ann-"+n)}case"x-threshold":{const t=Rn(null!=e.value?{...e,x:e.value}:e,o);if(null==t)return null;const r=e.color||"#f97316",i=e.labelPosition||"top";let a;a="bottom"===i?(o.height||0)-4:"center"===i?(o.height||0)/2:16;const s=t>.6*(o.width||0),l=s?t-4:t+4,c=s?"end":"start";return Jn("g",{opacity:e.opacity,children:[Kn("line",{x1:t,y1:0,x2:t,y2:o.height||0,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&Kn(Fn,{x:l,y:a,text:e.label,textAnchor:c,fill:r,fontSize:12,fontWeight:"bold",background:e.labelBackground??"halo"})]},"ann-"+n)}case"y-threshold":{const t=Ln(null!=e.value?{...e,y:e.value}:e,o);if(null==t)return null;const r=e.color||"#f97316",i=e.labelPosition||"right";let s,l;"left"===i?(s=4,l="start"):"center"===i?(s=(o.width||0)/2,l="middle"):(s=(o.width||0)-4,l="end");const c=20>(a=t)?Math.min((o.height||0)-4,a+16):a-4;return Jn("g",{opacity:e.opacity,children:[Kn("line",{x1:0,y1:t,x2:o.width||0,y2:t,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&Kn(Fn,{x:s,y:c,text:e.label,textAnchor:l,fill:r,fontSize:12,fontWeight:"bold",background:e.labelBackground??"halo"})]},"ann-"+n)}case"enclose":{const t=(e.coordinates||[]).map(e=>({x:Rn({...e,type:"point"},o),y:Ln({...e,type:"point"},o),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>t.length)return null;const r=pn(t),i=e.padding||10;return Jn("g",{children:[Kn("circle",{cx:r.x,cy:r.y,r:r.r+i,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&Kn(Fn,{x:r.x,y:r.y-r.r-i-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:e.label,background:e.labelBackground??"none"})]},"ann-"+n)}case"rect-enclose":{const t=(e.coordinates||[]).map(e=>({x:Rn({...e,type:"point"},o),y:Ln({...e,type:"point"},o)})).filter(e=>null!=e.x&&null!=e.y);if(2>t.length)return null;const r=e.padding||10,i=t.map(e=>e.x),a=t.map(e=>e.y),[s,l]=ae(i),[c,u]=ae(a),d=s-r,h=l+r,f=c-r;return Jn("g",{children:[Kn("rect",{x:d,y:f,width:h-d,height:u+r-f,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&Kn(Fn,{x:(d+h)/2,y:f-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:e.label,background:e.labelBackground??"none"})]},"ann-"+n)}case"highlight":{const t=o.data||[],r="function"==typeof e.filter?t.filter(e.filter):e.field&&null!=e.value?t.filter(t=>t[e.field]===e.value):[],i={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return Kn("g",{children:r.map((t,n)=>{const r=Rn(t,o),a=Ln(t,o);if(null==r||null==a)return null;const s="function"==typeof e.r?e.r(t):e.r||6,l="function"==typeof e.style?e.style(t):e.style||i;return Kn("circle",{cx:r,cy:a,r:s,...l},"hl-"+n)})},"ann-"+n)}case"bracket":{const t=Rn(e,o),r=Ln(e,o);return Kn(fn,{noteData:{x:t??0,y:r??0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}},"ann-"+n)}case"trend":{const t=o.data||[];if(2>t.length)return null;const r=o.xAccessor||"x",i=o.yAccessor||"y",a="ordinal"===o.frameType,s="horizontal"===o.projection,l=a?r:null,c=a?i:null;let u;const d=[],h=new Map;if(a&&l&&c){for(const e of t){const t=e[l];if(null==t)continue;const n=t+"";h.has(n)||(h.set(n,d.length),d.push(n))}u=t.map(e=>{const t=e[l],n=e[c];if(null==t||null==n)return null;const o=h.get(t+"");return null!=o?[o,+n]:null}).filter(e=>null!==e)}else u=t.map(e=>[e[r],e[i]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>u.length)return null;const f=o.scales?.x??o.scales?.time,p=o.scales?.y??o.scales?.value;if(!f||!p)return null;const m=e=>t=>{const n=Math.max(0,Math.floor(t)),o=Math.min(d.length-1,n+1),r=t-n,i=e(d[n]);return i+(e(d[o])-i)*r},y=f,g=p;let b;if(a)if(s){const e=m(g);b=(t,n)=>[y(n),e(t)]}else{const e=m(y);b=(t,n)=>[e(t),g(n)]}else b=(e,t)=>[y(e),g(t)];const v=e.method||"linear";let x;if("loess"===v)x=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,h=0,f=0,p=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(u+=t,d+=t*r[e],h+=t*i[e],f+=t*r[e]*r[e],p+=t*r[e]*i[e])}if(0===u){s.push([t,i[e]]);continue}const m=u*f-d*d;if(1e-12>Math.abs(m))s.push([t,h/u]);else{const e=(u*p-d*h)/m;s.push([t,(h-e*d)/u+e*t])}}return s}(u,e.bandwidth??.3);else{const t="polynomial"===v?Mn(u,e.order||2):function(e){const t=[0,0,0,0];let n=0;for(const[o,r]of e)null!==r&&(n++,t[0]+=o,t[1]+=r,t[2]+=o*o,t[3]+=o*r);const o=n*t[2]-t[0]*t[0],r=0===o?0:Cn((n*t[3]-t[0]*t[1])/o),i=Cn(t[1]/n-r*t[0]/n);return{points:e.map(([e])=>[Cn(e),Cn(r*e+i)]),equation:[r,i]}}(u);x=t.points}const w=x.map(([e,t])=>{const[n,o]=b(e,t);return`${n},${o}`}).join(" "),k=e.color||"#6366f1",S=x[x.length-1],[A,C]=b(S[0],S[1]);return Jn("g",{children:[Kn("polyline",{points:w,fill:"none",stroke:k,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&Kn("text",{x:A+4,y:C-4,fill:k,fontSize:11,children:e.label})]},"ann-"+n)}case"band":{const t=o.scales?.y??o.scales?.value,a=t?.(e.y0)??0,s=t?.(e.y1)??(o.height||0),l=Qn(e.fill,"ann-"+n,"var(--semiotic-primary, #6366f1)");return Jn("g",{opacity:e.opacity,children:[l.def&&Kn("defs",{children:l.def}),Kn("rect",{x:0,y:Math.min(a,s),width:o.width||0,height:Math.abs(s-a),fill:l.fill,fillOpacity:e.fillOpacity||.1}),e.label&&Kn(Fn,{x:(o.width||0)-4,y:(r=a,i=s,Math.max(Math.min(r,i),0)+16),textAnchor:"end",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",text:e.label,background:e.labelBackground??"halo"})]},"ann-"+n)}case"x-band":{const t=o.scales?.x??o.scales?.time,r=null!=e.x0&&t?t(e.x0):null,i=null!=e.x1&&t?t(e.x1):null;if(null==r||null==i)return null;const a=Qn(e.fill||e.color,"ann-"+n,"var(--semiotic-primary, #6366f1)");return Jn("g",{opacity:e.opacity,children:[a.def&&Kn("defs",{children:a.def}),Kn("rect",{x:Math.min(r,i),y:0,width:Math.abs(i-r),height:o.height||0,fill:a.fill,fillOpacity:e.fillOpacity??.1}),e.label&&Kn(Fn,{x:Math.min(r,i)+4,y:16,textAnchor:"start",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",text:e.label,background:e.labelBackground??"halo"})]},"ann-"+n)}case"envelope":{const t=o.data||[];if(2>t.length)return null;const r=o.xAccessor||"x",i=o.scales?.x??o.scales?.time,a=o.scales?.y??o.scales?.value;if(!i||!a)return null;const s=e.upperAccessor||"upperBounds",l=e.lowerAccessor||"lowerBounds",c=e.filter,u=t.filter(e=>null!=e[s]&&null!=e[l]&&!(c&&!c(e))).sort((e,t)=>e[r]-t[r]);if(2>u.length)return null;const d=eo[o.curve||"linear"]||yn,h=mn().x(e=>i(e[r])).y0(e=>a(e[l])).y1(e=>a(e[s])).curve(d)(u);if(!h)return null;const f=e.fill||"#6366f1";return Jn("g",{children:[Kn("path",{d:h,fill:f,fillOpacity:e.fillOpacity??.15,stroke:"none"}),e.label&&u.length>0&&Kn("text",{x:i(u[u.length-1][r])+4,y:a(u[u.length-1][s])-4,fill:f,fontSize:11,children:e.label})]},"ann-"+n)}case"anomaly-band":{const t=o.data||[];if(2>t.length)return null;const r=o.yAccessor||"y",i=o.scales?.x??o.scales?.time,a=o.scales?.y??o.scales?.value;if(!i||!a)return null;const s=t.map(e=>e[r]).filter(e=>null!=e&&isFinite(e));if(2>s.length)return null;const l=s.reduce((e,t)=>e+t,0)/s.length,c=s.reduce((e,t)=>e+(t-l)**2,0)/s.length,u=Math.sqrt(c),d=e.threshold??2,h=l-d*u,f=!1!==e.showBand,p=e.fill||"#6366f1",m=e.fillOpacity??.1,y=e.anomalyColor||"#ef4444",g=e.anomalyRadius??6,b=a(l+d*u),v=a(h),x=t.filter(e=>{const t=e[r];return null!=t&&Math.abs(t-l)>d*u});return Jn("g",{children:[f&&Kn("rect",{x:0,y:Math.min(b,v),width:o.width||0,height:Math.abs(v-b),fill:p,fillOpacity:m}),x.map((e,t)=>{const n=Rn(e,o),r=Ln(e,o);return null==n||null==r?null:Kn("circle",{cx:n,cy:r,r:g,fill:y,fillOpacity:.7,stroke:y,strokeWidth:1.5},"anomaly-"+t)}),e.label&&Kn("text",{x:(o.width||0)-4,y:Math.min(b,v)-4,textAnchor:"end",fill:p,fontSize:11,children:e.label})]},"ann-"+n)}case"forecast":{const t=o.data||[];if(3>t.length)return null;const r=o.xAccessor||"x",i=o.yAccessor||"y",a=o.scales?.x??o.scales?.time,s=o.scales?.y??o.scales?.value;if(!a||!s)return null;const l=t.map(e=>[e[r],e[i]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>l.length)return null;let c;if("polynomial"===(e.method||"linear")){const t=Mn(l,e.order||2).equation;c=e=>t.reduce((t,n,o)=>t+n*Math.pow(e,o),0)}else{const e=l.length;let t=0,n=0,o=0,r=0;for(const[e,i]of l)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;c=e=>s+a*e}const u=l.length,d=l.map(([e,t])=>t-c(e)),h=d.reduce((e,t)=>e+t*t,0),f=Math.sqrt(h/Math.max(u-2,1)),p=l.reduce((e,t)=>e+t[0],0)/u,m=l.reduce((e,t)=>e+(t[0]-p)**2,0),y=e.confidence??.95,g=.99>y?.95>y?.9>y?1:1.645:1.96:2.576,b=e.steps??5,v=l[u-1][0],x=(v-l[0][0])/Math.max(u-1,1),w=[];for(let e=1;b>=e;e++)w.push(v+e*x);const k=[];for(const e of w){const t=c(e),n=f*Math.sqrt(1+1/u+(m>0?(e-p)**2/m:0))*g;k.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const S=`M${k.map(e=>`${a(e.x)},${s(e.yUpper)}`).join(" L")} L${k.slice().reverse().map(e=>`${a(e.x)},${s(e.yLower)}`).join(" L")} Z`,A=k.map(e=>`${a(e.x)},${s(e.yCenter)}`).join(" "),C=`${a(v)},${s(c(v))}`,M=e.strokeColor||"#6366f1";return Jn("g",{children:[Kn("path",{d:S,fill:e.fill||"#6366f1",fillOpacity:e.fillOpacity??.15,stroke:"none"}),Kn("polyline",{points:`${C} ${A}`,fill:"none",stroke:M,strokeWidth:e.strokeWidth??2,strokeDasharray:e.strokeDasharray??"6,3"}),e.label&&k.length>0&&Kn("text",{x:a(k[k.length-1].x)+4,y:s(k[k.length-1].yCenter)-4,fill:M,fontSize:11,children:e.label})]},"ann-"+n)}case"widget":{let r,i;if(null!=e.px&&null!=e.py)r=e.px,i=e.py;else{const t=In(e,n,o);if(!t)return null;r=t.x,i=t.y}if(!Tn(r,i,o))return null;const a=e.dx??0,s=e.dy??0,l=e.width??32,c=e.height??32,u=e.content??Kn("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info",children:"ℹ️"});return Kn("foreignObject",{x:r+a-l/2,y:i+s-c/2,width:l,height:c,style:{overflow:"visible",pointerEvents:"auto"},children:Kn("div",{...en(e,t),style:{width:l,height:c,display:"flex",alignItems:"center",justifyContent:"center"},children:u})},"ann-"+n)}case"text":{const t=In(e,n,o);if(!t)return null;const{x:r,y:i}=t,a=r+(e.dx||0),s=i+(e.dy||0),l=e.color||"var(--semiotic-text, #333)",c=Kn("text",{x:a,y:s,fill:l,fontSize:e.fontSize||11,opacity:e.opacity,strokeDasharray:e.strokeDasharray,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:e.label});return!0!==e._redundantConnector?on.cloneElement(c,{key:"ann-text-"+n}):Jn("g",{opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:[Kn("line",{x1:r,y1:i,x2:a,y2:s,stroke:l,strokeWidth:1,strokeOpacity:.5,style:{pointerEvents:"none"}}),on.cloneElement(c,{opacity:void 0,strokeDasharray:void 0})]},"ann-text-"+n)}case"category-highlight":{const t=e.category;if(null==t)return null;const r=e=>"function"==typeof e&&"function"==typeof e.bandwidth,i=o.scales?.o,a=o.scales?.x,s=o.scales?.y,l=r(i)?i:r(a)?a:r(s)?s:null;if(!l)return null;const c=l(t+"");if(null==c)return null;const u=l.bandwidth(),d=e.color||"var(--semiotic-primary, #4589ff)",h=e.opacity??.15,f=e.label;return Jn("g",(o.projection?"vertical"===o.projection:l===a)?{children:[Kn("rect",{x:c,y:0,width:u,height:o.height||0,fill:d,fillOpacity:h}),f&&Kn(Fn,{x:c+u/2,y:16,textAnchor:"middle",fill:d,fontSize:12,fontWeight:"bold",text:f,background:e.labelBackground??"none"})]}:{children:[Kn("rect",{x:0,y:c,width:o.width||0,height:u,fill:d,fillOpacity:h}),f&&Kn(Fn,{x:12,y:c+u/2,dominantBaseline:"middle",fill:d,fontSize:12,fontWeight:"bold",text:f,background:e.labelBackground??"none"})]},"ann-"+n)}default:return null}var r,i,a}}(0,S),void 0,e)},[y,w,t,n,k,S]);return a||s||l||m||M&&M.length>0?Oo("svg",{role:"img",width:o,height:r,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[zo("title",{children:"string"==typeof s?s:"XY Chart"}),zo("desc",{children:"string"==typeof s?s+" — XY data visualization":"XY data visualization"}),Oo("g",{transform:"translate("+i.left+","+i.top+")",children:[M,m]}),s&&"string"==typeof s?zo("text",{x:o/2,y:22,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)"},children:s}):s?zo("foreignObject",{x:0,y:0,width:o,height:i.top,children:s}):null,Do({legend:l,totalWidth:o,totalHeight:r,margin:i,legendPosition:f,title:s,legendLayout:p,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h})]}):null}import*as Bo from"react";import{arc as Eo}from"d3-shape";import{jsx as Wo,jsxs as _o}from"react/jsx-runtime";function Ho(e,t="#4e79a7"){return Vn(e)?e.background&&"transparent"!==e.background?e.background:t:e&&"string"==typeof e?e:t}var Fo="undefined"==typeof window||"undefined"==typeof document;import{useEffect as $o,useLayoutEffect as Go,useRef as qo,useState as Vo,useSyncExternalStore as Uo}from"react";var Zo="undefined"!=typeof window?Go:$o,Yo=()=>()=>{},Xo=()=>!1,Qo=()=>!0;import{useEffect as Ko,useRef as Jo}from"react";import{jsx as er}from"react/jsx-runtime";function tr({children:e,size:t,margin:n,overflowVisible:o=!1}){return e?er("svg",{style:{position:"absolute",left:0,top:0,width:t[0],height:t[1],pointerEvents:"none",overflow:o?"visible":void 0},children:er("g",{transform:`translate(${n.left},${n.top})`,children:e})}):null}import{useRef as nr}from"react";function or(e,t){const n=Object.keys(e),o=Object.keys(t);if(n.length!==o.length)return!1;for(const o of n){if(!Object.prototype.hasOwnProperty.call(t,o))return!1;if(!Object.is(e[o],t[o]))return!1}return!0}function rr(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(!Object.is(e[n],t[n]))return!1;return!0}function ir(e){if(null===e||"object"!=typeof e)return!1;if(Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}import*as ar from"react";import*as sr from"react";import{jsx as lr}from"react/jsx-runtime";var cr=sr.createContext(null);import{jsx as ur}from"react/jsx-runtime";var dr={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function hr({hoverPoint:e}){let t="";if(e){const n=e.data||e;t="object"==typeof n?"Data point: "+Object.entries(n).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Data point: "+n}return ur("div",{"aria-live":"polite","aria-atomic":"true",style:dr,children:t})}function fr(e){const t={};if(null==e||"object"!=typeof e)return t;for(const[n,o]of Object.entries(e))n.startsWith("_")||null!=o&&""!==o&&("number"==typeof o?Number.isFinite(o)&&(t[n]=o):"string"==typeof o?t[n]=o:"boolean"==typeof o?t[n]=o+"":o instanceof Date&&(t[n]=o.toISOString().slice(0,10)));return t}function pr(e){return e&&"object"==typeof e?e:{}}function mr(e){return pr(e.accessibility).tableFields??e.accessibleDatum??e.datum}import{jsx as yr,jsxs as gr}from"react/jsx-runtime";function br(e,t){if(!e||0===e.length)return t+", empty";const n={};for(const t of e){if(null===t?.datum)continue;const e=t.type+"";n[e]=(n[e]||0)+1}if(0===Object.keys(n).length)return t+", empty";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(", ")}`}var vr=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},xr="semiotic-accessible-data-table",wr=xr+" semiotic-accessible-data-table-hidden",kr=xr+" semiotic-accessible-data-table-visible",Sr={position:"absolute",top:0,left:0,right:0,zIndex:"var(--semiotic-data-table-z-index, var(--semiotic-overlay-z-index, 20))",padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-data-table-border, 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-data-table-text, var(--semiotic-text, #333))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},Ar={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},Cr={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",cursor:"pointer",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},Mr={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},Rr={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))"},Lr={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},jr={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",marginBottom:4,fontStyle:"italic"},Pr={marginTop:8,padding:"4px 10px",fontSize:12,cursor:"pointer",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",borderRadius:"var(--semiotic-border-radius, 4px)",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",fontFamily:"inherit"};function Ir({scene:e,chartType:t,tableId:n,chartTitle:o}){const[r,i]=ar.useState(!1),[a,s]=ar.useState(5),l=sr.useContext(cr),c=l?.visible??!1,u=r||c,d=ar.useRef(null),h=o?"Data summary for "+o:n?`Data summary for ${t} ${n}`:"Data summary for "+t;ar.useEffect(()=>{u||s(5)},[u]);const f=ar.useCallback(e=>{e.target===e.currentTarget&&(r||c||i(!0))},[r,c]),p=ar.useCallback(e=>{c||d.current?.contains(e.relatedTarget)||i(!1)},[c]);if(!e||0===e.length)return n?yr("span",{id:n,tabIndex:-1,style:dr}):null;if(!u)return yr("div",{id:n,className:wr,tabIndex:-1,onFocus:f,style:dr,role:"region","aria-label":h,children:gr("button",{type:"button",onClick:()=>i(!0),children:["View data summary (",e.length," elements)"]})});const m=function(e){const t=[];if(!Array.isArray(e))return t;const n=e.some(e=>e&&("line"===e.type||"area"===e.type));for(const o of e)if(o&&"object"==typeof o&&null!==o.datum)try{switch(o.type){case"point":if(n)break;t.push({label:"Point",values:fr(mr(o))});break;case"line":case"area":{const e=mr(o),n=Array.isArray(e)?e:[],r="line"===o.type?"Line point":"Area point";for(const e of n)t.push({label:r,values:fr(e)});break}case"rect":{const e=mr(o),n=null!=e&&"object"==typeof e?e:{},r=n.category??o.group??"",i=n.value??n.__aggregateValue??n.total,a=fr(n);null==a.category&&""!==r&&(a.category=r+""),null==a.value&&null!=i&&(a.value="number"==typeof i||"string"==typeof i?i:i+""),t.push({label:"Bar",values:a});break}case"heatcell":{const e=fr(mr(o));null==e.value&&"number"==typeof o.value&&Number.isFinite(o.value)&&(e.value=o.value),t.push({label:"Cell",values:e});break}case"wedge":{const e=mr(o),n=fr(e);if(null==n.category){const t=pr(e),o=t.category??t.label;null!=o&&(n.category=o+"")}t.push({label:"Wedge",values:n});break}case"circle":t.push({label:"Node",values:fr(mr(o))});break;case"arc":t.push({label:"Arc",values:fr(mr(o))});break;case"candlestick":t.push({label:"Candlestick",values:fr(mr(o))});break;case"geoarea":{const e=pr(mr(o)),n=fr(e);if(null==n.name){const t=pr(e.properties).name??e.name;null!=t&&(n.name=t+"")}t.push({label:"Region",values:n});break}}}catch{}return t}(e),y=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}(m),g=function(e,t){const n=[e+" data points."];for(const e of t)if(e.numeric)n.push(`${e.name}: ${vr(e.min)} to ${vr(e.max)}, mean ${vr(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(" ")}(m.length,y),b=Math.min(a,m.length),v=m.slice(0,b),x=m.length-b,w=new Set;for(const e of v)for(const t of Object.keys(e.values))w.add(t);const k=Array.from(w);return gr("div",{ref:d,id:n,className:kr,tabIndex:-1,onBlur:p,style:Sr,role:"region","aria-label":h,children:[yr("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{c&&l&&l.setVisible(!1),i(!1)},"aria-label":"Close data summary",style:Cr,children:"×"}),yr("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:Ar,children:g}),gr("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Sample data for "+t,style:Mr,children:[yr("caption",{className:"semiotic-accessible-data-table-caption",style:jr,children:x>0?`First ${b} of ${m.length} data points`:`All ${m.length} data points`}),yr("thead",{children:gr("tr",{children:[yr("th",{style:Rr,children:"type"}),k.map(e=>yr("th",{style:Rr,children:e},e))]})}),yr("tbody",{children:v.map((e,t)=>gr("tr",{children:[yr("td",{style:Lr,children:e.label}),k.map(t=>{return yr("td",{style:Lr,children:(n=e.values[t],null==n||""===n?"—":"number"==typeof n?Number.isNaN(n)?"—":vr(n):"boolean"==typeof n?n?"true":"false":"object"==typeof n?"—":n+"")},t);var n})]},t))})]}),x>0&&gr("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>s(e=>e+25),style:Pr,children:["Show ",Math.min(25,x)," more"," ",1===x?"row":"rows"," (",x," remaining)"]})]})}function Tr({summary:e}){return e?yr("div",{role:"note",style:dr,children:e}):null}function Dr({tableId:e}){return yr("a",{href:"#"+e,style:dr,onClick:t=>{t.preventDefault();const n=document.getElementById(e);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,dr)},children:"Skip to data table"})}import{useCallback as zr,useRef as Or}from"react";var Nr=Object.freeze([]);function Br(e){if(!e)return Nr;let t=!1;for(let n=0;e.length>n;n++){const o=e[n];if(null==o||"object"!=typeof o){t=!0;break}}if(!t)return e;const n=[];for(const t of e)null!=t&&"object"==typeof t&&n.push(t);return n}import{jsx as Er}from"react/jsx-runtime";var Wr="var(--semiotic-focus, #005fcc)";function _r({active:e,hoverPoint:t,margin:n,size:o,shape:r="circle",width:i,height:a,pathData:s}){if(!e||!t)return null;const l=t.x+n.left,c=t.y+n.top;let u;if("geoarea"!==r&&"path"!==r||!s)if("rect"===r&&null!=i&&null!=a){const e=Math.max(i,4),t=Math.max(a,4);u=Er("rect",{x:l-e/2-3,y:c-t/2-3,width:e+6,height:t+6,rx:3,fill:"none",stroke:Wr,strokeWidth:2,strokeDasharray:"4,2"})}else u=Er("circle","wedge"===r?{cx:l,cy:c,r:12,fill:"none",stroke:Wr,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:l,cy:c,r:8,fill:"none",stroke:Wr,strokeWidth:2,strokeDasharray:"4,2"});else u=Er("g",{transform:`translate(${n.left},${n.top})`,children:Er("path",{d:s,fill:"none",stroke:Wr,strokeWidth:2.5,strokeDasharray:"6,3"})});return Er("svg",{style:{position:"absolute",left:0,top:0,width:o[0],height:o[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}import*as Hr from"react";function Fr(e,t){return"touch"===t?Math.max(e,24):e}var $r=["name","label","title"],Gr=["type","kind","category","group","class","status","role","shape"],qr=["value","amount","total","count","weight","score"],Vr=new Set(["x","y","z","x0","x1","y0","y1","r","cx","cy","radius","layer","row","rowindex","col","column","depth","index","order","sankeywidth","coincidentpoints","sourcelinks","targetlinks","parent","children","fx","fy","vx","vy"]);function Ur(e,t){for(const n of t){const t=e.find(e=>e.lower===n);if(t)return t}}import{jsx as Zr,jsxs as Yr}from"react/jsx-runtime";var Xr={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 Qr(e,t){return"function"==typeof t?t(e):e[t]}function Kr(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 Jr(e={}){const{fields:t,title:n,format:o,style:r={},className:i=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let a;const s=[];if(n){const t=Qr(e,n);a=Kr(t,o)}if(t&&t.length>0)t.forEach(t=>{let n,r,i;"string"==typeof t?(n=t,r=t,i=o):(n=t.label,r=t.accessor||t.key||"",i=t.format||o);const a=Qr(e,r);s.push({label:n,value:Kr(a,i)})});else if(!n){const t=["value","y","name","id","label"];for(const n of t)if(void 0!==e[n]){a=Kr(e[n],o);break}if(!a){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(a=Kr(e[t[0]],o))}}const l={...Xr,...r};return Yr("div",{className:("semiotic-tooltip "+i).trim(),style:l,children:[a&&Zr("div",{style:{fontWeight:s.length>0?"bold":"normal"},children:a}),s.map((e,t)=>Yr("div",{style:{marginTop:0===t&&a?"4px":0},children:[e.label&&Yr("span",{children:[e.label,": "]}),e.value]},t))]})}}function ei(e){if(!0!==e){if("function"==typeof e){const t=e;return e=>{let n=Array.isArray(o=!0===e?.__semioticHoverData||e&&void 0!==e.data&&"number"==typeof e.x&&"number"==typeof e.y&&e&&("node"===e.type||"edge"===e.type||void 0!==e.nodeOrEdge||void 0!==e.allSeries||void 0!==e.stats||void 0!==e.__chartType)?e.data??{}:e)?o[0]:o;var o;if(!n)return null;if(("node"===e?.nodeOrEdge&&"number"==typeof n?.x0&&"number"==typeof n?.x1||"edge"===e?.nodeOrEdge&&"number"==typeof n?.sankeyWidth)&&n.data&&"object"==typeof n.data&&(n=n.data),!n)return null;const r=t(n);return null==r?null:Zr("div",{className:"semiotic-tooltip",style:Xr,children:r})}}return!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?Jr(e):Jr())}}import{jsx as ti}from"react/jsx-runtime";function ni({x:e,y:t,containerWidth:n,containerHeight:o,margin:r,children:i,className:a="stream-frame-tooltip",zIndex:s=1}){const l=Number.isFinite(e)&&Number.isFinite(t),c=Hr.useRef(null),[u,d]=Hr.useState(null);Hr.useLayoutEffect(()=>{const e=c.current;if(!e)return;const t=()=>{const t=e.getBoundingClientRect();Number.isFinite(t.width)&&Number.isFinite(t.height)&&d(e=>e&&.5>Math.abs(e.width-t.width)&&.5>Math.abs(e.height-t.height)?e:{width:t.width,height:t.height})};if(t(),"undefined"==typeof ResizeObserver)return;const n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[a,n,o,l]);let h;h=u?`translate(${u.width+12>n-e?"calc(-100% - 12px)":"12px"}, ${u.height+12>o-t?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*n?"calc(-100% - 12px)":"12px"}, ${.3*o>t?"4px":"calc(-100% - 4px)"})`;const f=function(e){if(!Hr.isValidElement(e))return!1;const t=e.type;if("string"!=typeof t&&t&&!0===t.ownsChrome)return!0;const n=e.props;if(!0===n["data-semiotic-tooltip-chrome"])return!0;if("true"===n["data-semiotic-tooltip-chrome"])return!0;const o=n.style;if(o&&"object"==typeof o){if(null!=o.background&&""!==o.background&&"transparent"!==o.background)return!0;if(null!=o.backgroundColor&&""!==o.backgroundColor&&"transparent"!==o.backgroundColor)return!0}return!1}(i),p=f?null:Xr;return l?ti("div",{ref:c,className:f?a:(a+" semiotic-tooltip").trim(),style:{...p||{},position:"absolute",left:r.left+e,top:r.top+t,transform:h,pointerEvents:"none",zIndex:s,width:"max-content"},children:i}):null}import{zoom as oi,zoomIdentity as ri}from"d3-zoom";import{select as ii}from"d3-selection";import{curveMonotoneX as ai,curveMonotoneY as si,curveCardinal as li,curveCatmullRom as ci,curveStep as ui,curveStepBefore as di,curveStepAfter as hi,curveBasis as fi,curveNatural as pi}from"d3-shape";function mi(e){switch(e){case"monotoneX":return ai;case"monotoneY":return si;case"cardinal":return li;case"catmullRom":return ci;case"step":return ui;case"stepBefore":return di;case"stepAfter":return hi;case"basis":return fi;case"natural":return pi;default:return null}}function yi(e,t,n){if(null==t)return n;if(Vn(t)){const o=function(e,t){const n="undefined"!=typeof window&&window.devicePixelRatio||1,o=`${Un(e)}@${n}`,r=Yn.get(o);if(void 0!==r)return r;const i=function(e={},t){const{background:n="transparent",stroke:o="#000",lineWidth:r=1.5,spacing:i=6,angle:a=45}=e,s=Math.max(8,Math.ceil(2*i));let l;try{l=function(e){return"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(e,e):($n||($n=document.createElement("canvas")),$n.width=e,$n.height=e,$n)}(s)}catch{return null}const c=l.getContext("2d");if(!c)return null;n&&"transparent"!==n?(c.fillStyle=n,c.fillRect(0,0,s,s)):c.clearRect(0,0,s,s),c.strokeStyle=o,c.lineWidth=r,c.lineCap="square";const u=a*Math.PI/180;if(45===a||-45===a){const e=a>0?1:-1;for(let t=-s;2*s>=t;t+=i)c.beginPath(),c.moveTo(t,0),c.lineTo(t+e*s,s),c.stroke()}else{c.save(),c.translate(s/2,s/2),c.rotate(u);const e=2*s;for(let t=-e;e>=t;t+=i)c.beginPath(),c.moveTo(-e,t),c.lineTo(e,t),c.stroke();c.restore()}return(t||c).createPattern(l,"repeat")}({background:e.background,stroke:e.stroke,lineWidth:e.lineWidth,spacing:e.spacing,angle:e.angle},t);return Yn.set(o,i),i}(t,e);return o||t.background&&Ot(e,t.background)||n}return"string"!=typeof t?t:Ot(e,t)||n}function gi(e,t){if(null==t)return;const n=yi(e,t,"");return""===n?void 0:n}function bi(e,t,n,o,r,i){const a=t.colorStops.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color}));if(2>a.length)return null;const s=e.createLinearGradient(n,o,r,i);for(const e of a)s.addColorStop(e.offset,e.color);return s}function vi(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function xi(e,t,n=.6){if(!vi(t))return;const o=t.r+(t._pulseGlowRadius??4)*t._pulseIntensity,r=t.cx??t.x??0,i=t.cy??t.y??0;e.beginPath(),e.arc(r,i,o,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 wi(e,t,n,o=.35){vi(t)&&(e.globalAlpha=t._pulseIntensity*o,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",n?e.fill(n):e.fill())}import{line as ki}from"d3-shape";function Si(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 Ai(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 Ci(e,t,n,o,r){if(0>=t.size)return;const i=t.glyph;if(!i||!i.parts?.length)return;const a=Ge(i,t.size);if(0>=a.scale)return;const s=(t.style.opacity??1)*(t._decayOpacity??1);if(0>=s)return;const l=t=>{const n=yi(e,t,t);return"string"==typeof n?n:t},c=t.color??("string"==typeof t.style.fill?t.style.fill:void 0);e.save(),e.translate(n,o),t.rotation&&e.rotate(t.rotation),e.translate(a.offsetX,a.offsetY),e.scale(a.scale,a.scale),e.globalAlpha=r*s*(t.style.fillOpacity??1);const u=Ye(i,t.fraction??1,t.fractionStart??0,t.fractionDirection??"horizontal");u&&t.ghostColor&&Qe(e,i,c,t.accent,t.ghostColor,l),u&&(e.beginPath(),e.rect(u.x,u.y,u.width,u.height),e.clip()),Qe(e,i,c,t.accent,void 0,l),e.restore()}function Mi(e,t,n,o){const r=e.getContext("2d");if(!r)return null;const i=Math.round(t[0]*o),a=Math.round(t[1]*o),s=i/t[0],l=a/t[1],c=t[0]+"px",u=t[1]+"px";return e.style.width!==c&&(e.style.width=c),e.style.height!==u&&(e.style.height=u),e.width===i&&e.height===a||(e.width=i,e.height=a),r.setTransform(s,0,0,l,0,0),r.translate(n.left,n.top),r}function Ri(){if("undefined"==typeof window)return 1;const e=window.devicePixelRatio||1,t=function(){if("undefined"==typeof window)return!1;const e="function"==typeof window.matchMedia&&window.matchMedia("(pointer: coarse)").matches,t=768>Math.min(window.innerWidth||1/0,window.innerHeight||1/0);return e||t}()?2:3;return Math.max(1,Math.min(e,t))}function Li([e,t,n]){const o=1<<n;return[e-Math.floor(e/o)*o,t,n]}function ji(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":"")}var Pi=class{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()}};var Ii=class{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,t=Math.random){for(let n=0;this.capacity>n;n++){const o=this.particles[n];if(!o.active)return o.active=!0,o.t=0,o.offset=.6*(t()-.5),o.lineIndex=e,o.x=0,o.y=0,o}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=Ti(a),l=Di(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 Ti(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 Di(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}}import*as zi from"react";function Oi(...e){const t=e.filter(e=>null!=e);return 0===t.length?null:1===t.length?t[0]:zi.createElement(zi.Fragment,null,...t)}import*as Ni from"react";import{jsx as Bi}from"react/jsx-runtime";var Ei=Ni.createContext(null);function Wi({value:e,children:t}){return Bi(Ei.Provider,{value:e,children:t})}function _i(e,t){return null!=e?Bi(Wi,{value:t,children:e}):e}var Hi=new Set;function Fi(e,t){const n="function"==typeof e?e(t.datum??null,t):e;return(o=n)&&"object"==typeof o&&"string"==typeof o.id&&"function"==typeof o.cacheKey&&"function"==typeof o.drawCanvas&&"function"==typeof o.renderStaticSVG?n:void 0;var o}function $i(e,t){if("undefined"!=typeof process&&"production"===process.env?.NODE_ENV)return;const n=`${e}:${t}`;Hi.has(n)||(Hi.add(n),console.warn(`[Semiotic] Render backend "${e}" does not support scene node "${t}"; using the built-in renderer.`))}function Gi(e){if(!e)return;const t=[];for(const n of e)if("point"===n.type)t.push(n);else if("glyph"===n.type){const e=n,o=Xe(e.glyph,e.size);t.push({pointId:e.pointId,x:e.x+o.centerDx,y:e.y+o.centerDy,r:o.radius})}return t}import{jsx as qi,jsxs as Vi}from"react/jsx-runtime";import{jsx as Ui,jsxs as Zi}from"react/jsx-runtime";function Yi({data:e}){if(!e)return null;if(e.properties)return Ui("div",{className:"semiotic-tooltip",style:Xr,children:Ui("div",{style:{fontWeight:600},children:e.properties.name||e.properties.NAME||e.properties.id||"Feature"})});const t=null!=e.data?e.data:e;if(!t||"object"!=typeof t)return null;const n=function(e,t={}){if(!e||"object"!=typeof e)return{entries:[]};const n=t.maxEntries??6,o=!1!==t.skipPositional,r=[];for(const[t,n]of Object.entries(e)){if(t.startsWith("_"))continue;if("data"===t)continue;if(o&&Vr.has(t.toLowerCase()))continue;if(null==n)continue;const e=typeof n;("string"===e||"number"===e||"boolean"===e||n instanceof Date)&&r.push({key:t,lower:t.toLowerCase(),value:n})}if(0===r.length)return{entries:[]};let i=r.findIndex(e=>$r.includes(e.lower));const a=i>=0;0>i&&(i=r.findIndex(e=>"id"===e.lower)),0>i&&(i=r.findIndex(e=>"string"==typeof e.value));const s=0>i?void 0:r[i];let l=r.filter((e,t)=>t!==i);a&&(l=l.filter(e=>"id"!==e.lower));const c=Ur(l,Gr),u=Ur(l,qr),d=new Set(Gr),h=new Set(qr),f=[];c&&f.push({key:c.key,value:c.value}),u&&f.push({key:u.key,value:u.value});for(const e of l){if(f.length>=n)break;e!==c&&e!==u&&(d.has(e.lower)||h.has(e.lower)||f.push({key:e.key,value:e.value}))}return{titleKey:s?.key,title:s?.value,entries:f}}(t),o=null!=n.title?n.title+"":null;return null==o&&0===n.entries.length?null:Zi("div",{className:"semiotic-tooltip",style:Xr,children:[null!=o&&Ui("div",{style:{fontWeight:600,marginBottom:n.entries.length?2:0},children:o}),n.entries.map(e=>{return Zi("div",{children:[Zi("span",{style:{opacity:.7},children:[e.key,": "]}),Ui("span",{style:{fontWeight:600},children:(t=e.value,null==t?"–":"number"==typeof t?Math.abs(t)>9999?t.toLocaleString():t+"":t instanceof Date?t.toLocaleDateString():t+"")})]},e.key);var t})]})}Yi.ownsChrome=!0;var Xi={top:10,right:10,bottom:10,left:10},Qi=null;function Ki(){if(null!==Qi)return Qi;if("undefined"==typeof window)return!1;const e="function"==typeof window.matchMedia&&window.matchMedia("(pointer: coarse)").matches,t="undefined"!=typeof navigator&&"number"==typeof navigator.hardwareConcurrency&&4>=navigator.hardwareConcurrency,n="undefined"!=typeof navigator&&"number"==typeof navigator.deviceMemory&&4>=navigator.deviceMemory;return Qi=e||t||n}function Ji(){return Ki()?12:30}var ea={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 ta(e){return"string"==typeof e?e:"object"==typeof e&&e&&"type"in e?e.type:null}function na(e){return e?e.getContext("2d"):null}function oa(e){const{onObservation:t,datum:n,x:o=0,y:r=0,chartType:i,chartId:a,context:s,timestamp:l=Date.now()}=e;t&&(n?(t({type:"hover",datum:n,x:o,y:r,timestamp:l,chartType:i,chartId:a}),"focus"===s?.type&&t({type:"focus",datum:n,inputType:"touch"===s.inputType?"pointer":s.inputType,timestamp:l,chartType:i,chartId:a})):t({type:"hover-end",timestamp:l,chartType:i,chartId:a}))}function ra(e){const{onObservation:t,datum:n,x:o=0,y:r=0,chartType:i,chartId:a,context:s,timestamp:l=Date.now()}=e;t&&(n?(t({type:"click",datum:n,x:o,y:r,timestamp:l,chartType:i,chartId:a}),"activate"===s?.type&&t({type:"activate",datum:n,inputType:s.inputType,timestamp:l,chartType:i,chartId:a})):t({type:"click-end",timestamp:l,chartType:i,chartId:a}))}import{useCallback as ia}from"react";import{useCallback as aa,useRef as sa}from"react";function la(e){const t=e.datum;return{...t||{},...t?.properties||{},data:t,properties:t?.properties,x:e.x,y:e.y,__semioticHoverData:!0}}import{jsx as ca,jsxs as ua}from"react/jsx-runtime";var da=s(a(function(a,s){const{projection:l,projectionExtent:c,fitPadding:u,projectionTransform:d,areas:h,points:f,lines:p,customLayout:m,layoutConfig:y,layoutSelection:g,onLayoutError:b,xAccessor:v,yAccessor:x,lineDataAccessor:w,pointIdAccessor:k,lineIdAccessor:S,lineType:A="geo",flowStyle:C="basic",graticule:M,zoomable:R,zoomExtent:L,onZoom:j,dragRotate:P,showParticles:I,particleStyle:T,tileURL:D,tileAttribution:z,tileCacheSize:O,size:N,width:B,height:E,responsiveWidth:W,responsiveHeight:_,margin:H,className:F,background:$,windowSize:G=500,renderMode:q,areaStyle:V,pointStyle:U,lineStyle:Z,colorScheme:Y,enableHover:X=!0,hoverAnnotation:Q,tooltipContent:K,allowTooltipOverflow:J=!1,customClickBehavior:ee,customHoverBehavior:te,onObservation:ne,annotationObservationCallback:oe,chartId:re,annotations:ie,onAnnotationActivate:ae,autoPlaceAnnotations:se,decay:le,pulse:ce,transition:ue,animate:de,staleness:he,frameScheduler:fe,clock:pe,random:me,seed:ye,paused:ge=!1,suspendWhenHidden:be=!0,backgroundGraphics:ve,foregroundGraphics:xe,title:we,legend:ke,legendPosition:Se,legendLayout:Ae,legendHoverBehavior:Ce,legendClickBehavior:Me,legendHighlightedCategory:Re,legendIsolatedCategories:Le,legendCategoryAccessor:je,onCategoriesChange:Ie,showAxes:Te,accessibleTable:ze=!0,description:Oe,summary:Ne}=a,{customHoverBehavior:Be,customClickBehavior:Ee,hasClickBehavior:He}=function({customHoverBehavior:e,customClickBehavior:t,onObservation:n,chartId:o,chartType:r}){return{customHoverBehavior:ia((t,i)=>{e?.(t,i),oa({onObservation:n,datum:t?t.data||t:null,x:t?.x,y:t?.y,chartType:r,chartId:o,context:i})},[o,r,e,n]),customClickBehavior:ia((e,i)=>{t?.(e,i),ra({onObservation:n,datum:e?e.data||e:null,x:e?.x,y:e?.y,chartType:r,chartId:o,context:i})},[o,r,t,n]),hasClickBehavior:!(!t&&!n)}}({customHoverBehavior:te,customClickBehavior:ee,onObservation:ne,chartId:re,chartType:"StreamGeoFrame"}),Fe=N||[B||600,E||400],$e=e(!0),qe=Ft({sizeProp:Fe,responsiveWidth:W,responsiveHeight:_,userMargin:H,marginDefault:Xi,title:we,legend:ke,legendPosition:Se,foregroundGraphics:xe,backgroundGraphics:ve,animate:de,transitionProp:ue,frameScheduler:fe,clock:pe,random:me,seed:ye,paused:ge,suspendWhenHidden:be,themeDirtyRef:$e}),{reducedMotionRef:Ue,responsiveRef:Ze,size:Qe,margin:Je,adjustedWidth:et,adjustedHeight:tt,resolvedForeground:nt,resolvedBackground:ot,transition:rt,introEnabled:it,tableId:at,frameRuntime:st,rafRef:lt,renderFnRef:ct,scheduleRender:ut,currentTheme:dt}=qe,ht=function(){const[e,t]=Vo(!1);return Zo(()=>{t(!0)},[]),e}(),ft=function(){const e=Uo(Yo,Xo,Qo);return qo(e).current}(),pt=o(()=>Array.isArray(h)?Br(h):h,[h]),yt=o(()=>Br(f),[f]),gt=o(()=>Br(p),[p]),bt=o(()=>null!=P?P:"orthographic"===ta(l),[P,l]),vt=function(e){const t=nr(e);return function(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return rr(e,t);if(!ir(e)||!ir(t))return!1;const n=Object.keys(e),o=Object.keys(t);if(n.length!==o.length)return!1;for(const o of n){if(!Object.prototype.hasOwnProperty.call(t,o))return!1;const n=e[o],r=t[o];if(!Object.is(n,r))if(Array.isArray(n)&&Array.isArray(r)){if(!rr(n,r))return!1}else{if(!ir(n)||!ir(r))return!1;if(!or(n,r))return!1}}return!0}(t.current,e)||(t.current=e),t.current}(o(()=>({projection:l,projectionExtent:c,fitPadding:u,xAccessor:v,yAccessor:x,lineDataAccessor:w,lineType:A,flowStyle:C,areaStyle:V,pointStyle:U,lineStyle:Z,colorScheme:Y,themeSemantic:mt(dt),themeSequential:dt?.colors?.sequential,themeDiverging:dt?.colors?.diverging,themeCategorical:dt?.colors?.categorical,graticule:M,projectionTransform:d,windowSize:G,clock:st.now,decay:le,pulse:ce,transition:rt,introAnimation:it,annotations:ie,pointIdAccessor:k,lineIdAccessor:S,customLayout:m,layoutConfig:y,onLayoutError:b,layoutMargin:Je}),[l,c,u,v,x,w,A,C,V,U,Z,Y,dt,M,d,G,st.now,le,ce,rt,it,ie,k,S,m,y,b,Je])),xt=e(null);xt.current||(xt.current=new Pe(vt));const wt=e(null),kt=e(null),St=e(null);D&&!St.current&&(St.current=new Pi(O||256));const At=e(ie),Ct=e(null),Mt=e(ri),Rt=e(!1),Lt=e(null),jt=r(e=>{Lt.current=e,Ze&&"object"==typeof Ze&&(Ze.current=e)},[Ze]),Pt=e(null),It=e(null),Tt=e(null),Dt=e(0);if(I&&!Tt.current){const e=T?.maxPerLine??Ji();Tt.current=new Ii(50*e)}const zt=e(null),Nt=e(null),Bt=e(!1),Et=e(!1),Wt=De(new We("StreamGeoFrame")),_t=e(void 0),[Ht,Yt]=t(null),[,Qt]=t(0),Kt=e(0),[Jt,en]=t(!1),tn=function(e,t,n,o){const r=Or({accessor:t,onChange:n,readData:o}),i=Or([]);return r.current={accessor:t,onChange:n,readData:o},zr(()=>{const{accessor:t,onChange:n,readData:o}=r.current;if(!n||!t)return;const a=function(e,t){if(!t)return[];const n=new Set,o=[];for(const r of e){if(!r||"object"!=typeof r)continue;const e="function"==typeof t?t(r):r[t];if(null==e)continue;const i=e+"";n.has(i)||(n.add(i),o.push(i))}return o}(e.current?o(e.current):[],t);(function(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(e[n]!==t[n])return!1;return!0})(a,i.current)||(i.current=a,n(a))},[e])}(xt,je,Ie,e=>e.getPoints());!function(e,t,n,o){$t(()=>{e.current?.updateConfig(t),n.current=!0,o()},[t,o,e,n])}(xt,vt,$e,ut),function(e,t,n,o){const r=Gt(null);$t(()=>{const i=e.current;if(!i)return;const a=t??null;r.current!==a&&(r.current=a,i.setLayoutSelection(a),i.hasCustomRestyle?i.restyleScene(a):n.current=!0,o())},[t,o,e,n])}(xt,g,$e,ut),n(()=>{const e=xt.current;e&&(pt&&e.setAreas(pt),f&&e.setPoints(yt),p&&e.setLines(gt),$e.current=!0,ut())},[pt,f,yt,p,gt,ut]);const nn=r(e=>{null!=e&&"object"==typeof e&&(xt.current?.pushPoint(e),$e.current=!0,ut())},[ut]),on=r(e=>{const t=Br(e);0!==t.length&&(xt.current?.pushMany(t),$e.current=!0,ut())},[ut]),rn=r(e=>{null!=e&&"object"==typeof e&&(xt.current?.pushLine(e),$e.current=!0,ut())},[ut]),an=r(e=>{const t=Br(e);0!==t.length&&(xt.current?.pushManyLines(t),$e.current=!0,ut())},[ut]),sn=r(()=>{xt.current?.clear(),$e.current=!0,ut()},[ut]);i(s,()=>({push:nn,pushMany:on,removePoint:e=>{const t=xt.current?.removePoint(e)??[];return t.length>0&&($e.current=!0,ut()),t},pushLine:rn,pushManyLines:an,removeLine:e=>{const t=xt.current?.removeLine(e)??[];return t.length>0&&($e.current=!0,ut()),t},getLines:()=>xt.current?.getLines()??[],clear:sn,getProjection:()=>xt.current?.scales?.projection??null,getGeoPath:()=>xt.current?.scales?.geoPath??null,getCartogramLayout:()=>xt.current?.cartogramLayout??null,getCustomLayout:()=>xt.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>xt.current?.lastCustomLayoutFailure??null,getZoom:()=>Mt.current.k,resetZoom:()=>{const e=Lt.current;e&&Ct.current&&ii(e).call(Ct.current.transform,ri)},getData:()=>xt.current?.getPoints()??[]}),[nn,on,rn,an,sn,ut]);const{hoverHandlerRef:ln,onPointerMove:cn,onPointerLeave:un}=qe,{canvasRef:dn,interactionCanvasRef:hn}=function(e,t){return function(e){const{cancelRender:t,dirtyRef:n,frameRuntime:o,manageFrameRuntime:r,scheduleRender:i}=e,a=Jo(null),s=Jo(null),l=Jo(!1);return function(e){const{hydrated:t,wasHydratingFromSSR:n,storeRef:o,dirtyRef:r,renderFnRef:i,cancelRender:a,cleanup:s}=e;Zo(()=>{t&&n&&o.current?.cancelIntroAnimation?.(),r.current=!0,a?.(),i.current()},[t,n]);const l=qo(s);l.current=s,$o(()=>()=>l.current?.(),[])}({hydrated:e.hydrated,wasHydratingFromSSR:e.wasHydratingFromSSR,storeRef:e.storeRef,dirtyRef:e.dirtyRef,renderFnRef:e.renderFnRef,cancelRender:e.cancelRender,cleanup:e.cleanup}),Ko(()=>{if(!1!==r)return o.subscribe(()=>{o.isActive?(n.current=!0,i()):t()})},[t,n,o,r,i]),Ko(()=>{!l.current&&(l.current=!0,e.skipInitialCanvasPaintInvalidation)||(e.dirtyRef.current=!0,e.scheduleRender())},e.canvasPaintDependencies),{canvasRef:a,interactionCanvasRef:s}}({...t,renderFnRef:e.renderFnRef,scheduleRender:e.scheduleRender,cancelRender:e.cancelRender,frameRuntime:e.frameRuntime})}(qe,{hydrated:ht,wasHydratingFromSSR:ft,storeRef:xt,dirtyRef:$e,cleanup:()=>St.current?.clear(),canvasPaintDependencies:[et,tt,$,ve,q,ut]});n(()=>{ln.current=e=>{if(!X)return;const t=xt.current;if(!t||!t.scene.length)return;const n=dn.current;if(!n)return;const o=n.getBoundingClientRect(),r=e.clientX-o.left-Je.left,i=e.clientY-o.top-Je.top;if(0>r||r>et||0>i||i>tt)return zt.current=null,Nt.current=null,Yt(null),Be?.(null),void ut();kt.current||(kt.current="undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(1,1):document.createElement("canvas"));const a=na(kt.current);if(!a)return;const s=Fr(30,e.pointerType),l=Fr(6,e.pointerType),c=Ke(t.scene,r,i,s,a,t.quadtree,t.maxPointRadius,l);if(c){const e=c.node,t=e.datum,n=Array.isArray(t)?null:t?.properties?t:t?.data||t;let o,a;"point"===e.type?(o=e.x,a=e.y):"geoarea"===e.type?(o=e.centroid[0],a=e.centroid[1]):(o=r,a=i);const s={...n,...n?.properties||{},data:n,properties:n?.properties,__semioticHoverData:!0,x:o,y:a};zt.current=s,Nt.current=e,Yt(s),Be?.(s),ut()}else zt.current&&(zt.current=null,Nt.current=null,Yt(null),Be?.(null),ut())}},[X,et,tt,Je,Be,ut,ln,dn]),qe.hoverLeaveRef.current=()=>{zt.current=null,Nt.current=null,Yt(null),Be?.(null),ut()};const fn=r(e=>{if((t=e.target)instanceof Element&&null!=t.closest("[data-semiotic-annotation-widget]"))return;var t;if(!Ee)return;const n=xt.current;if(!n||!n.scene.length)return void Ee(null);const o=e.currentTarget.getBoundingClientRect(),r=e.clientX-o.left-Je.left,i=e.clientY-o.top-Je.top;if(0>r||r>et||0>i||i>tt)return void Ee(null);kt.current||(kt.current="undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(1,1):document.createElement("canvas"));const a=na(kt.current);if(!a)return void Ee(null);const s=Fr(30,_t.current),l=Fr(6,_t.current),c=Ke(n.scene,r,i,s,a,n.quadtree,n.maxPointRadius,l);if(c){const e=c.node.datum,t=Array.isArray(e)?null:e?.properties?e:e?.data||e,n=t?.properties?{...t,...t.properties}:t;return void Ee({...n,data:t,properties:t?.properties,__semioticHoverData:!0,x:r,y:i,time:r,value:i},{type:"activate",inputType:(u=_t.current,"touch"===u?"touch":"pointer")})}var u;Ee(null)},[tt,et,Ee,Je]),{kbFocusIndexRef:pn,focusedNavPointRef:mn,onKeyDown:yn}=function({storeRef:e,hoverRef:t,hoveredNodeRef:n,setHoverPoint:o,customHoverBehavior:r,customClickBehavior:i,scheduleRender:a}){const s=sa(-1),l=sa(null),c=aa(c=>{if(function(e){const t=e.target;return t instanceof Element&&t!==e.currentTarget&&null!=t.closest("button, a[href], input, select, textarea, summary, [contenteditable='true'], [role='button'], [role='link'], [role='checkbox'], [role='radio'], [role='switch']")}(c))return;const u=e.current;if(!u)return;const d=()=>{s.current=-1,l.current=null,t.current=null,n&&(n.current=null),o(null),r(null),a()};if(0===u.scene.length)return void(0>s.current||d());const h=function(e){const t=[];for(const n of e)if("point"===n.type&&null!=n.x)t.push({x:n.x,y:n.y,datum:n.datum,shape:"circle"});else if("glyph"===n.type){if(0>=n.size||null==n.datum)continue;const e=Xe(n.glyph,n.size);t.push({x:n.x+e.centerDx,y:n.y+e.centerDy,datum:n.datum,shape:"rect",w:2*e.halfWidth,h:2*e.halfHeight})}else"geoarea"===n.type&&n.centroid&&!1!==n.interactive&&t.push({x:n.centroid[0],y:n.centroid[1],datum:n.datum,shape:"geoarea",pathData:n.pathData});return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(u.scene);if(0===h.length)return void(0>s.current||d());let f=s.current;if(h.length>f||(d(),f=-1),("Enter"===c.key||" "===c.key)&&f>=0)return c.preventDefault(),void i(la(h[f]),{type:"activate",inputType:"keyboard"});const p=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}}(c.key,0>f?-1:f,h.length);if(null===p)return;if(c.preventDefault(),0>p)return void d();const m=0>f?0:p;s.current=m;const y=h[m];l.current=y;const g=la(y);t.current=g,o(g),r(g,{type:"focus",inputType:"keyboard"}),a()},[i,r,t,n,a,o,e]);return{kbFocusIndexRef:s,focusedNavPointRef:l,onKeyDown:c}}({storeRef:xt,hoverRef:zt,hoveredNodeRef:Nt,setHoverPoint:Yt,customHoverBehavior:Be,customClickBehavior:Ee,scheduleRender:ut}),gn=r(e=>{_t.current=e.pointerType,pn.current=-1,mn.current=null,cn(e)},[mn,pn,cn]),bn=r(e=>{_t.current=e.pointerType},[]);ct.current=()=>{if(lt.current=null,!st.isActive)return;const e=dn.current,t=xt.current;if(!e||!t)return;const n=st.now();let o=!1;const r=It.current;let i=!1;r&&(It.current=null,t.applyRotation(r,{width:et,height:tt}),i=!0);const a=t.advanceTransition(Ue.current?n+1e6:n),s=!Ue.current&&a,l=Wt.current.beforeCompute(t.getLastUpdateResult(),s);let c=!1;if($e.current&&!a){const n={width:et,height:tt},o=bt?t.getRotation():null;t.computeScene(n);const r=Mt.current,i=1!==r.k||0!==r.x||0!==r.y;bt&&o?i?(t.setRotation(o),t.applyZoomScale(r.k,n)):t.applyRotation(o,n):i&&t.applyZoomTransform(r,n),$e.current=!1,c=!0,e.setAttribute("aria-label",br(t.scene,"Geographic chart")),tn()}Wt.current.afterCompute(l,c,!1);const u=Ri(),d=I&&!Ue.current&&!!Tt.current,h=t.consumeStylePaintPending(),f=function(e,t,n,o){const r=o.current,i=!0===e.lastCustomLayoutFailure?.preservedLastGoodScene,a=!i&&e.hasActivePulsesAt(t),s=!(n||i||!a&&!r)&&e.refreshPulse(t);return o.current=a,{changed:s,pending:a}}(t,n,c,Et),p=!!((m={dirtyOrRebuilt:c,transitioning:s,continuous:d,liveEncoding:f.changed,forced:i||h}).dirtyOrRebuilt||m.transitioning||m.animationTicked||m.continuous||m.liveEncoding||m.forced);var m;if(D&&St.current){const e=wt.current;if(e&&t.scales?.projection){const n=Mi(e,Qe,Je,u);if(n){n.clearRect(-Je.left,-Je.top,Qe[0],Qe[1]),n.save(),n.beginPath(),n.rect(0,0,et,tt),n.clip();const e=function(e,t){const{tileURL:n,projection:o,width:r,height:i,tileCache:a,onTileLoad:s}=t,l=o.scale(),c=o.translate(),u=function(e){const{size:t,scale:n,translate:o,clampX:r=!0,clampY:i=!0}=e,a=Math.max(Math.log(n)/Math.LN2-8,0),s=Math.round(a),l=1<<s,c=Math.pow(2,a-s+8),u=o[0]-n/2,d=o[1]-n/2,h=Math.max(r?0:-1/0,Math.floor((0-u)/c)),f=Math.min(r?l:1/0,Math.ceil((t[0]-u)/c)),p=Math.max(i?0:-1/0,Math.floor((0-d)/c)),m=Math.min(i?l:1/0,Math.ceil((t[1]-d)/c)),y=[];for(let e=p;m>e;++e)for(let t=h;f>t;++t)y.push([t,e,s]);return{tiles:y,translate:[u/c,d/c],scale:c}}({size:[r,i],scale:2*l*Math.PI,translate:c}),d=Ri();let h=!0;for(const t of u.tiles){const[o,r,i]=Li(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,s?.()},e.onerror=()=>{t.loaded=!0},e.src=ji(n,i,o,r,d),c=t}if(!c.loaded){h=!1;continue}const f=u.scale;e.drawImage(c.img,(t[0]+u.translate[0])*f-.5,(t[1]+u.translate[1])*f-.5,f+1,f+1)}return h}(n,{tileURL:D,projection:t.scales.projection,width:et,height:tt,tileCache:St.current,onTileLoad:()=>ut()});n.restore(),e||(o=!0)}}}if(p){const r=Mi(e,Qe,Je,u);if(!r)return;r.clearRect(-Je.left,-Je.top,Qe[0],Qe[1]),D||function(e,t){const{background:n,hasBackgroundGraphics:o=!1,themeBackground:r="",x:i=0,y:a=0,width:s,height:l}=t;if("transparent"===n)return!1;if(o)return!1;const c=n||(r&&"transparent"!==r?r:"")||null;if(!c)return!1;const u=Ot(e,c);u&&(e.fillStyle=u,e.fillRect(i,a,s,l))}(r,{background:$,hasBackgroundGraphics:!!ve,width:et,height:tt}),r.save(),r.beginPath(),r.rect(0,0,et,tt),r.clip();const i=t.scene,a={width:et,height:tt};if(function(e){const{context:t,nodes:n,renderMode:o,pixelRatio:r,paintBuiltIn:i}=e;if(!o||"sketchy"===o)return void i(n);let a=[];const s=()=>{a.length&&(i(a),a=[])};for(const e of n){const n=Fi(o,e);if(!n){a.push(e);continue}let l;s(),t.save();try{l=n.drawCanvas({context:t,node:e,style:e.style??{},pixelRatio:r})}finally{t.restore()}l||($i(n.id,e.type??"unknown"),i([e]))}s()}({context:r,nodes:i,renderMode:q,pixelRatio:u,paintBuiltIn:e=>{!function(e,t){const n=t.filter(e=>"geoarea"===e.type);for(const t of n){if(!t.pathData)continue;t._cachedPath2D||(t._cachedPath2D=new Path2D(t.pathData));const n=t._cachedPath2D,o=gi(e,t.style.fill)||"#e0e0e0";if("none"!==o&&(e.fillStyle=o,e.globalAlpha=(t._decayOpacity??1)*(t.style.fillOpacity??1),e.fill(n)),t.style.stroke&&"none"!==t.style.stroke){if(e.strokeStyle=Ot(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||.5,e.globalAlpha=t._decayOpacity??1,t.style.strokeDasharray){const n=t.style.strokeDasharray.split(",").map(Number);e.setLineDash(n)}else e.setLineDash([]);e.stroke(n)}wi(e,t,n),e.globalAlpha=1,e.setLineDash([])}}(r,e),((e,t,n,o)=>{const r=t.filter(e=>"line"===e.type);for(const t of r){if(2>t.path.length)continue;const n=t._introClipFraction;void 0!==n&&1>n&&(e.save(),e.beginPath(),e.rect(0,0,o.width*n,o.height),e.clip());const r=t.style.stroke||"#007bff",i=Ot(e,r)||r,a=t.style.strokeWidth||2,s=t.colorThresholds,l=t.rawValues;if(e.setLineDash(t.style.strokeDasharray?t.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),e.lineWidth=a,e.lineCap=t.style.strokeLinecap||"butt",t.style._edgeFade){Ai(e,t.path,i,a,t.style.opacity??1,t.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const c=mi(t.curve),u=s&&s.length>0&&l&&l.length===t.path.length,d=t._decayOpacities;if(d&&d.length===t.path.length&&!u){e.strokeStyle=i;const n=t.style.opacity??1;for(let o=0;t.path.length-1>o;o++)e.globalAlpha=.5*(d[o]+d[o+1])*n,e.beginPath(),e.moveTo(t.path[o][0],t.path[o][1]),e.lineTo(t.path[o+1][0],t.path[o+1][1]),e.stroke()}else if(u){let n=function(t,n,o){e.beginPath(),e.strokeStyle=t,e.moveTo(n,o),d=!0},o=function(){d&&(e.stroke(),d=!1)},r=null,a=null,c=null,u=null,d=!1;for(let d=0;t.path.length>d;d++){const[h,f]=t.path[d],p=l[d],m=Si(p,s,i);if(null!==r&&null!==u&&null!==c){if(m===u)e.lineTo(h,f);else{const t=[];for(const e of s){const n=e.value;(c>n||n>p)&&(n>c||p>n)||c===n||p===n||t.push({t:(n-c)/(p-c)})}t.sort((e,t)=>e.t-t.t);for(const l of t){const t=r+(h-r)*l.t,u=a+(f-a)*l.t,d=Si(c+(p-c)*Math.min(l.t+1e-4,1),s,i);e.lineTo(t,u),o(),n(d,t,u)}e.lineTo(h,f)}r=h,a=f,c=p,u=m}else n(m,h,f),r=h,a=f,c=p,u=m}o()}else{e.beginPath();const n=t.strokeGradient&&t.path.length>=2?bi(e,t.strokeGradient,t.path[0][0],0,t.path[t.path.length-1][0],0):null;if(e.strokeStyle=n||i,c)ki().x(e=>e[0]).y(e=>e[1]).curve(c).context(e)(t.path);else{const[n,o]=t.path[0];e.moveTo(n,o);for(let n=1;t.path.length>n;n++)e.lineTo(t.path[n][0],t.path[n][1])}e.stroke()}if(t.style.fill&&t.style.fillOpacity&&t.style.fillOpacity>0){if(e.beginPath(),e.globalAlpha=t.style.fillOpacity,e.fillStyle=yi(e,t.style.fill,t.style.fill),c&&!u)ki().x(e=>e[0]).y(e=>e[1]).curve(c).context(e)(t.path);else{const[n,o]=t.path[0];e.moveTo(n,o);for(let n=1;t.path.length>n;n++)e.lineTo(t.path[n][0],t.path[n][1])}const n=t.path[0][0];e.lineTo(t.path[t.path.length-1][0],o.height),e.lineTo(n,o.height),e.closePath(),e.fill()}void 0!==n&&1>n&&e.restore(),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}})(r,e,0,a),((e,t)=>{const n=t.filter(e=>"point"===e.type);if(0!==n.length){e.save();try{const t=e.globalAlpha;for(const o of n)e.beginPath(),e.arc(o.x,o.y,o.r,0,2*Math.PI),e.globalAlpha=t*(o.style.opacity??o.style.fillOpacity??1),e.fillStyle=yi(e,o.style.fill,"#4e79a7"),e.fill(),o.style.stroke&&(e.strokeStyle=yi(e,o.style.stroke,o.style.stroke),e.lineWidth=o.style.strokeWidth||1,e.stroke()),xi(e,o)}finally{e.restore()}}})(r,e),((e,t)=>{const n=e.globalAlpha;for(const o of t)"glyph"===o.type&&Ci(e,o,o.x,o.y,n);e.globalAlpha=n})(r,e)}}),d&&Tt.current){const e=Tt.current,t=i.filter(e=>"line"===e.type);if(t.length>0){const i=T||{},a=.3*(i.speedMultiplier??1),s=i.maxPerLine??Ji(),l=i.spawnRate??(Ki()?.06:.15),c=i.radius??2,u=i.opacity??.7,d=n/1e3,h=Dt.current>0?Math.min(d-Dt.current,.1):.016;Dt.current=d;const f=t.map(e=>e.path),p=t.map(e=>e.style.strokeWidth||2);for(let n=0;t.length>n;n++)st.random()<l&&e.countForLine(n)<s&&e.spawn(n,st.random);e.step(h,a,f,p),r.globalAlpha=u;for(let n=0;e.particles.length>n;n++){const o=e.particles[n];if(!o.active)continue;const a=t[o.lineIndex],s="function"==typeof i.color?i.color(a?.datum??{}):"source"!==i.color&&i.color?i.color:a?.style.stroke||"#fff";r.beginPath(),r.arc(o.x,o.y,c,0,2*Math.PI),r.fillStyle=s,r.fill()}r.globalAlpha=1,o=!0}}r.restore()}const y=Nt.current,g=!(!y||"geoarea"!==y.type&&"point"!==y.type),b=g||Bt.current;const v=hn.current;if(v&&b){const e=Mi(v,Qe,Je,u);if(e){if(e.clearRect(-Je.left,-Je.top,Qe[0],Qe[1]),y&&"geoarea"===y.type){const t=new Path2D(y.pathData);e.fillStyle="rgba(255, 255, 255, 0.3)",e.fill(t),e.strokeStyle="rgba(0, 0, 0, 0.5)",e.lineWidth=2,e.stroke(t)}if(y&&"point"===y.type){const t=y,n="object"==typeof Q?Q:void 0,o=n?.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}(y);e.beginPath(),e.arc(t.x,t.y,t.r+3,0,2*Math.PI),o?(e.save(),e.globalAlpha=.4,e.fillStyle=o,e.fill(),e.restore()):(e.fillStyle="rgba(255, 255, 255, 0.4)",e.fill()),e.strokeStyle=o||"rgba(0, 0, 0, 0.5)",e.lineWidth=2,e.stroke()}}Bt.current=g}const x=ie!==At.current;x&&(At.current=ie),(c||x||s&&ie&&ie.length>0)&&(c||x||n-Kt.current>=33)&&(Qt(e=>e+1),Kt.current=n),(s||null!=t.activeTransition||f.pending||o)&&ut()},function(e,t,n,o,r,i){const a=Vt("fresh");qt(()=>{if(!e)return;const s=setInterval(()=>{const s=t.current;if(!s||0===s.lastIngestTime)return;const l="undefined"!=typeof performance?performance.now():Date.now(),c=function(e,t){if(!e||0>=t)return Zt;const n=null!=e.threshold&&e.threshold>0?e.threshold:5e3,o=e.graded;if(o){const e="object"==typeof o?o:{},r=function(e,t,n={}){return Number.isFinite(t)&&t>0?Number.isNaN(e)?"fresh":e===1/0?"expired":0>e||t*(n.fresh??1)>e?"fresh":t*(n.aging??1.5)>e?"aging":t*(n.stale??3)>e?"stale":"expired":"fresh"}(t,n,e.thresholds);return{alpha:{...Ut,...e.opacities??{}}[r],band:r,isStale:"fresh"!==r}}return t>n?{alpha:e.dimOpacity??.5,band:"stale",isStale:!0}:Zt}(e,l-s.lastIngestTime);c.band===a.current&&c.isStale===r||(a.current=c.band,c.isStale!==r&&i(c.isStale),n.current=!0,o())},1e3);return()=>clearInterval(s)},[e,r,o,t,i,n])}(he,xt,$e,ut,Jt,en),n(()=>{if("production"!==process.env.NODE_ENV&&D){const e=ta(l);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.`)}},[D,l]),n(()=>{const e=Lt.current;if(!R||!e)return Ct.current&&e&&(ii(e).on(".zoom",null),Ct.current=null),void(e&&ii(e).on("mousedown.rotate",null).on("touchstart.rotate",null));const[t,n]=L||[1,8],o={width:et,height:tt};if(bt){let r=Mt.current.k;const i=e=>{r=Math.max(t,Math.min(n,e)),Mt.current=ri.scale(r);const i=xt.current;i&&(i.applyZoomScale(r,o),$e.current=!1,ut(),i.scales?.projection&&j?.({projection:i.scales.projection,zoom:i.currentZoom}))};Ct.current={scaleBy:(e,t)=>i(r*t),transform:(e,t)=>i(t?.k??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=xt.current;if(!o)return;const r=o.getRotation();Pt.current={x:t.clientX,y:t.clientY,rotation:[...r]},e.setPointerCapture(t.pointerId),t.preventDefault()},u=e=>{const t=Pt.current;t&&(It.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]],ut())},d=t=>{if(!Pt.current)return;Pt.current=null,e.releasePointerCapture(t.pointerId);const n=It.current;if(n){It.current=null;const e=xt.current;e&&(e.applyRotation(n,o),ut())}const r=xt.current;r?.scales?.projection&&j?.({projection:r.scales.projection,zoom:r.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),Ct.current=null}}const r=oi().scaleExtent([t,n]).extent([[0,0],[Qe[0],Qe[1]]]).translateExtent([[-1/0,-1/0],[1/0,1/0]]).on("zoom",e=>{const t=e.transform;Mt.current=t,Rt.current=!0;const n=xt.current;n&&(n.applyZoomTransform(t,o),$e.current=!1,ut())}).on("end",e=>{Mt.current=e.transform,Rt.current=!1;const t=xt.current;t?.scales?.projection&&j?.({projection:t.scales.projection,zoom:t.currentZoom})});return Ct.current=r,ii(e).call(r),()=>{ii(e).on(".zoom",null)}},[R,L,bt,Qe,et,tt,Je,j,ut]);const vn=X&&!1!==Q,xn=vn&&Ht?K?K(Ht):ca(Yi,{data:Ht}):null,wn=xn?ca(ni,{x:Ht.x,y:Ht.y,containerWidth:et,containerHeight:tt,margin:Je,className:"stream-frame-tooltip",zIndex:10,children:xn}):null;if(Fo||!ht&&ft){const e=xt.current;e&&(pt||f||p)&&(pt&&e.setAreas(pt),f&&e.setPoints(yt),p&&e.setLines(gt),e.computeScene({width:et,height:tt}));const t=e?.scene??[];return ua("div",{ref:jt,className:"stream-geo-frame"+(F?" "+F:""),role:"img","aria-label":Oe||("string"==typeof we?we:"Geographic chart"),style:{position:"relative",width:W?"100%":Qe[0],height:_?"100%":Qe[1]},children:[ca(Tr,{summary:Ne}),ua("svg",{xmlns:"http://www.w3.org/2000/svg",width:Qe[0],height:Qe[1],style:{position:"absolute",left:0,top:0},children:[ca("g",{transform:`translate(${Je.left},${Je.top})`,children:ot}),ua("g",{transform:`translate(${Je.left},${Je.top})`,children:[$&&ca("rect",{x:0,y:0,width:et,height:tt,fill:$}),t.map((e,t)=>function(e){const{node:t,index:n,renderMode:o,fallback:r}=e,i=Fi(o,t);if(!i)return r();const a=i.renderStaticSVG({node:t,style:t.style??{},key:`${i.id}-${n}`});return null!=a?a:($i(i.id,t.type??"unknown"),r())}({node:e,index:t,renderMode:q,fallback:()=>function(e,t){switch(e.type){case"geoarea":{const n=e;if(!n.pathData)return null;const o=Vn(n.style.fill)?Xn(n.style.fill,`geoarea-${t}-hatch`):void 0;return _o(Bo.Fragment,{children:[o&&Wo("defs",{children:o}),Wo("path",{d:n.pathData,fill:o?`url(#geoarea-${t}-hatch)`:Ho(n.style.fill,"#e0e0e0"),fillOpacity:n.style.fillOpacity??1,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth||.5,strokeDasharray:n.style.strokeDasharray,opacity:n._decayOpacity??1})]},"geoarea-"+t)}case"point":{const n=e,o=Vn(n.style.fill)?Xn(n.style.fill,`geopoint-${t}-hatch`):void 0;return _o(Bo.Fragment,{children:[o&&Wo("defs",{children:o}),Wo("circle",{cx:n.x,cy:n.y,r:n.r,fill:o?`url(#geopoint-${t}-hatch)`:Ho(n.style.fill),fillOpacity:n.style.fillOpacity??.8,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n._decayOpacity??n.style.opacity??1})]},"point-"+t)}case"line":{const n=e;if(2>n.path.length)return null;const o="M"+n.path.map(e=>`${e[0]},${e[1]}`).join("L");return Wo("path",{d:o,fill:"none",stroke:n.style.stroke||"#4e79a7",strokeWidth:n.style.strokeWidth||1.5,strokeDasharray:n.style.strokeDasharray,opacity:n.style.opacity??1},"line-"+t)}case"glyph":return function(e,t,n,o){const r=e.glyph;if(!r?.parts?.length||0>=e.size)return null;const i=Ge(r,e.size);if(0>=i.scale)return null;const a=`translate(${t},${n})${e.rotation?` rotate(${180*e.rotation/Math.PI})`:""} translate(${i.offsetX},${i.offsetY}) scale(${i.scale})`,s=e.color??("string"==typeof e.style.fill?e.style.fill:void 0),l=Ye(r,e.fraction??1,e.fractionStart??0,e.fractionDirection??"horizontal"),c=l?function(e){const t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"s_"+t:t}(o+"-clip"):void 0,u=(e.style.opacity??1)*(e._decayOpacity??1)*(e.style.fillOpacity??1),d=t=>r.parts.map((n,o)=>{const r=t?"none"===n.fill?void 0:t:Ve(n.fill,s,e.accent),i=t?n.stroke&&"none"!==n.stroke?t:void 0:Ve(n.stroke??"none",s,e.accent);return r||i?Wo("path",{d:n.d,fill:r??"none",stroke:i,strokeWidth:i?n.strokeWidth??1:void 0,strokeLinecap:n.strokeLinecap,strokeLinejoin:n.strokeLinejoin,opacity:n.opacity},o):null});return _o("g",{transform:a,opacity:1===u?void 0:u,children:[l&&c&&Wo("clipPath",{id:c,children:Wo("rect",{x:l.x,y:l.y,width:l.width,height:l.height})}),l&&e.ghostColor?Wo("g",{children:d(e.ghostColor)}):null,l&&c?Wo("g",{clipPath:`url(#${c})`,children:d()}):d()]},o)}(e,e.x,e.y,"geo-glyph-"+(e.pointId??t));default:return null}}(e,t)}))]})]}),ca(No,{width:et,height:tt,totalWidth:Qe[0],totalHeight:Qe[1],margin:Je,showAxes:!1,title:we,legend:ke,legendPosition:Se,legendLayout:Ae,legendHoverBehavior:Ce,legendClickBehavior:Me,legendHighlightedCategory:Re,legendIsolatedCategories:Le,foregroundGraphics:Oi(nt,_i(xt.current?.customLayoutOverlays,g??null)),annotations:ie,onAnnotationActivate:ae,onObservation:oe??ne,chartId:re,chartType:"StreamGeoFrame",autoPlaceAnnotations:se,pointNodes:Gi(t)})]})}return ua("div",{ref:jt,className:"stream-geo-frame"+(F?" "+F:""),role:"group","aria-label":Oe||("string"==typeof we?we:"Geographic chart"),tabIndex:0,style:{position:"relative",width:W?"100%":Qe[0],height:_?"100%":Qe[1],overflow:J?"visible":"hidden",...R?{touchAction:"none"}:{}},onKeyDown:yn,children:["production"!==process.env.NODE_ENV&&xt.current&&ca(_e,{store:xt.current,diagnostics:Wt.current}),ze&&ca(Dr,{tableId:at}),ze&&ca(Ir,{scene:xt.current?.scene??[],chartType:"Geographic chart",tableId:at,chartTitle:"string"==typeof we?we:void 0}),ca(Tr,{summary:Ne}),ca(hr,{hoverPoint:Ht}),ua("div",{role:"img","aria-label":Oe||("string"==typeof we?we:"Geographic chart"),style:{position:"relative",width:"100%",height:"100%"},onPointerMove:vn?gn:void 0,onPointerLeave:vn?un:void 0,onPointerDown:vn||He?bn:void 0,onClick:He?fn:void 0,children:[ca(tr,{size:Qe,margin:Je,children:ot}),D&&ca("canvas",{ref:wt,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),ca("canvas",{ref:dn,"aria-label":br(xt.current?.scene??[],"Geographic chart"),style:{position:"absolute",left:0,top:0}}),ca("canvas",{ref:hn,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),ca(No,{width:et,height:tt,totalWidth:Qe[0],totalHeight:Qe[1],margin:Je,showAxes:Te,title:we,legend:ke,legendPosition:Se,legendLayout:Ae,legendHoverBehavior:Ce,legendClickBehavior:Me,legendHighlightedCategory:Re,legendIsolatedCategories:Le,foregroundGraphics:Oi(nt,_i(xt.current?.customLayoutOverlays,g??null)),annotations:ie,onAnnotationActivate:ae,onObservation:oe??ne,chartId:re,chartType:"StreamGeoFrame",autoPlaceAnnotations:se,pointNodes:Gi(xt.current?.scene)}),he?.showBadge&&ca(Xt,{isStale:Jt,position:he.badgePosition}),R&&ua("div",{className:"stream-geo-zoom-controls",style:{position:"absolute",bottom:Je.bottom+8,left:Je.left+8,display:"flex",flexDirection:"column",gap:2,zIndex:2},children:[ca("button",{type:"button","aria-label":"Zoom in",onClick:e=>{e.stopPropagation();const t=Lt.current,n=Ct.current;t&&n?.scaleBy&&n.scaleBy(ii(t),1.5)},style:ea,children:"+"}),ca("button",{type:"button","aria-label":"Zoom out",onClick:e=>{e.stopPropagation();const t=Lt.current,n=Ct.current;t&&n?.scaleBy&&n.scaleBy(ii(t),1/1.5)},style:ea,children:"−"})]}),z&&ca("div",{className:"stream-geo-tile-attribution",style:{position:"absolute",bottom:Je.bottom+2,right:Je.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},children:z}),ca(_r,{active:pn.current>=0,hoverPoint:Ht,margin:Je,size:Qe,shape:mn.current?.shape,width:mn.current?.w,height:mn.current?.h,pathData:mn.current?.pathData}),wn]})]})}));da.displayName="StreamGeoFrame";var ha=da;import{useMemo as fa}from"react";function pa(e){if(null==e)return;if("number"==typeof e)return{top:e,right:e,bottom:e,left:e};const t={};return"number"==typeof e.top&&(t.top=e.top),"number"==typeof e.right&&(t.right=e.right),"number"==typeof e.bottom&&(t.bottom=e.bottom),"number"==typeof e.left&&(t.left=e.left),t}import{useMemo as ma,useCallback as ya,useState as ga,useId as ba,useEffect as va,useRef as xa}from"react";import{createContext as wa,useContext as ka,useMemo as Sa}from"react";import{jsx as Aa}from"react/jsx-runtime";var Ca=wa(null);function Ma(){return ka(Ca)}import{createContext as Ra,useContext as La,useEffect as ja,useId as Pa,useLayoutEffect as Ia,useMemo as Ta,useRef as Da,useState as za,useCallback as Oa}from"react";function Na(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 Ba(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}function Ea(e,t){if(e.type!==t.type)return!1;if("interval"===e.type&&"interval"===t.type)return e.range[0]===t.range[0]&&e.range[1]===t.range[1];if("point"===e.type&&"point"===t.type){if(e.values.size!==t.values.size)return!1;for(const n of e.values)if(!t.values.has(n))return!1;return!0}return!1}var[Wa,_a]=ft(e=>({selections:new Map,setClause(t,n){e(e=>{const o=e.selections.get(t),r=o?.clauses.get(n.clientId);if(r&&function(e,t){if(e.clientId!==t.clientId||e.type!==t.type)return!1;const n=Object.entries(e.fields);if(n.length!==function(e){let t=0;for(const n in e)t++;return t}(t.fields))return!1;for(const[e,o]of n){const n=t.fields[e];if(!n||!Ea(o,n))return!1}return!0}(r,n))return{};const i=new Map(e.selections),a=Ba(i,t),s=new Map(a.clauses);return s.set(n.clientId,n),i.set(t,{...a,clauses:s}),{selections:i}})},clearClause(t,n){e(e=>{const o=e.selections.get(t);if(!o||!o.clauses.has(n))return{};const r=new Map(e.selections),i=new Map(o.clauses);return i.delete(n),r.set(t,{...o,clauses:i}),{selections:r}})},setResolution(t,n){e(e=>{const o=e.selections.get(t);if(o?.resolution===n)return{};const r=new Map(e.selections),i=Ba(r,t);return r.set(t,{...i,resolution:n}),{selections:r}})},clearSelection(t){e(e=>{const n=e.selections.get(t);if(!n||0===n.clauses.size)return{};const o=new Map(e.selections);return o.set(t,{...n,clauses:new Map}),{selections:o}})}}));import{useId as Ha,useMemo as Fa,useCallback as $a}from"react";import{useSyncExternalStore as Ga}from"react";var qa={positions:new Map},Va=new Set;function Ua(){for(const e of Va)e()}function Za(e,t){const n=qa.positions.get(e);if(n?.locked)return;if(!n||n.sourceId!==t)return;const o=new Map(qa.positions);o.delete(e),qa={positions:o},Ua()}function Ya(e,t){const n=qa.positions.get(e);if(!n?.locked)return;if(t&&n.sourceId!==t)return;const o=new Map(qa.positions);o.delete(e),qa={positions:o},Ua()}function Xa(e){const t=Ha(),n=e.clientId||t,{name:o}=e,r=_a(e=>e.selections.get(o)),i=_a(e=>e.setClause),a=_a(e=>e.clearClause),s=Fa(()=>!!r&&r.clauses.size>0,[r]);return{predicate:Fa(()=>r&&0!==r.clauses.size?function(e,t){const n=[];for(const[o,r]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(Na(r));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(r,n):()=>!0,[r,n]),isActive:s,selectPoints:$a(e=>{const t={};let r=!1;for(const[n,o]of Object.entries(e))t[n]={type:"point",values:new Set(o)},r=!0;r&&i(o,{clientId:n,type:"point",fields:t})},[n,o,i]),selectInterval:$a(e=>{const t={};let r=!1;for(const[n,o]of Object.entries(e))t[n]={type:"interval",range:o},r=!0;r&&i(o,{clientId:n,type:"interval",fields:t})},[n,o,i]),clear:$a(()=>{a(o,n)},[a,o,n]),clientId:n}}function Qa(e){const t=e.name||"hover",{fields:n}=e,{predicate:o,isActive:r,selectPoints:i,clear:a}=Xa({name:t,fields:n});return{onHover:$a(e=>{if(!e)return void a();const t={};for(const o of n){const n=e[o];void 0!==n&&(t[o]=[n])}(function(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1})(t)&&i(t)},[n,i,a]),predicate:o,isActive:r}}import{jsx as Ka,jsxs as Ja}from"react/jsx-runtime";var es=Ra(!1);Ra(!1);var ts=Ra(null),ns="undefined"==typeof window?ja:Ia;function os(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,seriesField:e.seriesField}:null}function rs(e,t,n){return t?(o,...r)=>{const i={...e(o,...r)};if(t.isActive)if(t.predicate(o))n?.selectedStyle&&Object.assign(i,n.selectedStyle);else{const e=n?.unselectedOpacity??.5;i.opacity=e,i.fillOpacity=e,i.strokeOpacity=e,n?.unselectedStyle&&Object.assign(i,n.unselectedStyle)}return i}:e}import*as is from"react";import{jsx as as,jsxs as ss}from"react/jsx-runtime";function ls(){return St(e=>e.theme)}function cs(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function us(e,t){const{when:n}=e,o=t.width,r=t.height,i=function(e){if("number"==typeof e.height&&e.height>0)return e.width/e.height}(t),a=function(e){if("number"==typeof e.height&&e.height>0)return e.height>e.width?"portrait":"landscape"}(t);return!("number"==typeof n.minWidth&&n.minWidth>o||"number"==typeof n.maxWidth&&o>n.maxWidth||"number"==typeof n.minHeight&&("number"!=typeof r||n.minHeight>r)||"number"==typeof n.maxHeight&&("number"!=typeof r||r>n.maxHeight)||"number"==typeof n.minAspectRatio&&("number"!=typeof i||n.minAspectRatio>i)||"number"==typeof n.maxAspectRatio&&("number"!=typeof i||i>n.maxAspectRatio)||n.orientation&&a!==n.orientation)}function ds(e,t,n=e.responsiveRules){if(!Array.isArray(n)||0===n.length)return{props:e,matches:[]};const o=n.map((e,t)=>({rule:e,index:t})).filter(e=>us(e.rule,t)).sort((e,t)=>("number"==typeof e.rule.priority?e.rule.priority:e.index)-("number"==typeof t.rule.priority?t.rule.priority:t.index));return{props:o.reduce((e,t)=>function(e,t){const n={...e,...t};for(const o of["margin","frameProps","mobileSemantics","style"])cs(e[o])&&cs(t[o])&&(n[o]={...e[o],...t[o]});return"string"==typeof e.className&&"string"==typeof t.className&&(n.className=`${e.className} ${t.className}`),n}(e,t.rule.transform),e),matches:o}}function hs(e,t,n){const o=e.xValue??t?.[n];if(null==o)return null;const r=Number(o);return Number.isFinite(r)?r:null}function fs(e){let t=e.data||e.datum||e;return Array.isArray(t)&&(t=t[0]),null!=e.xValue&&t&&"object"==typeof t&&!Array.isArray(t)&&null==t.xValue?{...t,xValue:e.xValue}:t||{}}function ps(e){if(!e)return!1;for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}is.createContext(void 0);var ms="#007bff",ys=[],gs={enabled:!0,tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:44,snap:"nearestDatum",brushHandleSize:44,standardControls:!1,enabled:!1,tapToSelect:!1,tapToLockTooltip:!1};function bs(e,t={}){const n=t.mobileSemantics?.interaction,o="number"==typeof n?.targetSize?n.targetSize:"number"==typeof t.mobileSemantics?.minimumHitTarget?t.mobileSemantics.minimumHitTarget:void 0,r="mobile"===t.mode||"number"==typeof t.width&&480>=t.width,i=!!n||void 0!==o,a=e&&"object"==typeof e?e:void 0;if(!1===e||!1===a?.enabled||void 0===e&&!r&&!i)return gs;const s=a??{};return{enabled:!0,tapToSelect:s.tapToSelect??!0,tapToLockTooltip:s.tapToLockTooltip??!0,clearSelection:s.clearSelection??"backgroundTap",targetSize:s.targetSize??o??44,snap:s.snap??"nearestDatum",brushHandleSize:s.brushHandleSize??44,standardControls:s.standardControls??!1}}function vs(){const e=ls(),t=e?.colors?.categorical;return t&&t.length>0?t:void 0}function xs({selection:e,linkedHover:t,fallbackFields:n=ys,unwrapData:o=!1,onObservation:r,chartType:i,chartId:a,onClick:s,hoverHighlight:l,colorByField:c,mobileInteraction:u}){const d=ba(),h=ma(()=>os(t,n),[t,n]),f=ma(()=>"series"===h?.mode?[h.seriesField||c||n[0]].filter(e=>!!e):h?.fields||n,[h,c,n]),p=Xa({name:e?.name||"__unused__",fields:f}),m=Qa({name:h?.name||"hover",fields:f}),y=Jt(e=>e.pushObservation),g=ya(e=>{r?.(e),y?.(e)},[r,y]),b=e?{isActive:p.isActive,predicate:p.predicate}:null,[v,x]=ga(null),w=xa(!1),k=c||n[0],S=ma(()=>{if(!l||null==v||!k)return null;const e=v,t=k;return{isActive:!0,predicate:n=>("string"==typeof n[t]?n[t]:(n[t]??"")+"")===e}},[l,v,k]),A=ya((e,n)=>{const o=!e&&w.current&&!!u?.enabled&&u.tapToLockTooltip;if(t)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"x-position"===h?.mode&&h.xField){const n=hs(e,t,h.xField);null!=n&&function(e,t,n){const o=qa.positions.get(e);o?.locked||o&&o.xValue===t&&o.sourceId===n||(qa={positions:new Map(qa.positions).set(e,{xValue:t,sourceId:n})},Ua())}(h.name||"hover",n,d)}"x-position"!==h?.mode&&m.onHover(t)}else"x-position"!==h?.mode||o||Za(h.name||"hover",d),"x-position"===h?.mode||o||m.onHover(null);if(l&&k)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=t?.[k];x(null!=n?n+"":null)}else o||x(null);(r||y)&&oa({onObservation:g,datum:e?fs(e):null,x:e?.x,y:e?.y,chartType:i||"unknown",chartId:a,context:n})},[t,m,h,d,r,i,a,y,g,l,k,u]),C=ya((n=!0)=>{w.current=!1,t&&"x-position"!==h?.mode&&m.onHover(null),e&&u?.tapToSelect&&p.clear(),n&&l&&x(null),"x-position"===h?.mode&&(Ya(h.name||"hover",d),Za(h.name||"hover",d))},[t,h,m,e,u,p,l,d]),M=ya((n,o)=>{const c=!!u?.enabled&&(u.tapToLockTooltip||u.tapToSelect),b=!!u?.enabled&&"backgroundTap"===u.clearSelection;if("x-position"===h?.mode&&h.xField&&n){let e=n.data||n.datum||n;Array.isArray(e)&&(e=e[0]);const t=hs(n,e,h.xField);null!=t&&function(e,t,n){const o=qa.positions.get(e);if(o?.locked){const t=new Map(qa.positions);return t.delete(e),qa={positions:t},Ua(),!1}qa={positions:new Map(qa.positions).set(e,{xValue:t,sourceId:n,locked:!0})},Ua()}(h.name||"hover",t,d)}if(c)if(n){w.current=!0;const o=fs(n);if(t&&"x-position"!==h?.mode&&m.onHover(o),e&&u?.tapToSelect&&f.length>0){const e={};for(const t of f){const n=o[t];void 0!==n&&(e[t]=[n])}ps(e)&&p.selectPoints(e)}if(l&&k){const e=o?.[k];x(null!=e?e+"":null)}}else b&&C();if(n||b){if(n&&s){let e=n.data||n.datum||n;Array.isArray(e)&&(e=e[0]),s(e,{x:n.x??0,y:n.y??0})}(r||y)&&ra({onObservation:g,datum:n?fs(n):null,x:n?.x,y:n?.y,chartType:i||"unknown",chartId:a,context:o})}},[s,r,y,g,i,a,h,d,u,t,m,e,p,f,l,k,C]);return va(()=>{if(!u?.enabled||"undefined"==typeof document)return;const e=e=>{"Escape"===e.key&&w.current&&C()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[u?.enabled,C]),va(()=>()=>{w.current&&C(!1)},[C]),va(()=>{if("x-position"!==h?.mode)return;const e=h.name||"hover";return()=>{Ya(e,d),Za(e,d)}},[h?.mode,h?.name,d]),{activeSelectionHook:b,hoverSelectionHook:S,customHoverBehavior:A,customClickBehavior:M,crosshairSourceId:d}}function ws({data:e,colorBy:t,colorScale:n,showLegend:o,legendPosition:r="right",userMargin:i,defaults:a={top:50,bottom:60,left:70,right:40},categories:s}){const l=La(es),c=null!==La(ts),u=void 0!==o?o:!l&&!!t,d=!!t&&(u||c),h=ma(()=>{if(!d)return[];if(void 0!==s)return s;const n=new Set;for(const o of e){const e="function"==typeof t?t(o):o[t];null!=e&&n.add(e+"")}return Array.from(n)},[s,t,e,d]);!function(e){const t=La(ts),n=Pa(),o=function(e){const t=new Set,n=[];for(const o of e)t.has(o)||(t.add(o),n.push(o));return n}(e),r=Da([]);(function(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(e[n]!==t[n])return!1;return!0})(r.current,o)||(r.current=o);const i=r.current;ns(()=>{if(t)return()=>t.unregisterCategories(n)},[t,n]),ns(()=>{t&&t.registerCategories(n,i)},[t,n,i])}(c&&t?h:[]);const f=ma(()=>{if(!u||!t)return;const o=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):N[i%N.length];return{label:r+"",color:s}}),label:""}]}}({data:e,colorBy:t,colorScale:n,getColor:E,categories:h});return 0!==o.legendGroups.reduce((e,t)=>e+t.items.length,0)?o:void 0},[u,t,e,n,h]),p=ma(()=>{const e="number"==typeof i?{top:i,bottom:i,left:i,right:i}:i??{},t=t=>{const n=e[t];return"number"==typeof n?n:a[t]},n={top:t("top"),right:t("right"),bottom:t("bottom"),left:t("left")},o=t=>"number"==typeof e[t];return f&&("right"===r&&!o("right")&&110>n.right?n.right=110:"left"===r&&!o("left")&&110>n.left?n.left=110:"top"===r&&!o("top")&&50>n.top?n.top=50:"bottom"===r&&!o("bottom")&&80>n.bottom&&(n.bottom=80)),n},[a,i,f,r]);return{legend:f,margin:p,legendPosition:r}}var ks={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}},mobile:{width:390,height:300,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:!1,showLabels:!0,marginDefaults:{top:28,bottom:42,left:44,right:16}}};function Ss(e,t,n){const o=ks[e||"primary"],r=e&&"primary"!==e||!n?.width?o.width:n.width,i=e&&"primary"!==e||!n?.height?o.height:n.height,a=ds({...t,mode:e},{width:t.width??r,height:t.height??i}).props,s=a.mode||e,l=ks[s||"primary"],c="context"===s||"sparkline"===s,u=s&&"primary"!==s||!n?.width?l.width:n.width;return{width:a.width??u,height:a.height??(s&&"primary"!==s||!n?.height?l.height:n.height),showAxes:a.showAxes??l.showAxes,showGrid:a.showGrid??l.showGrid,enableHover:a.enableHover??(!!a.linkedHover||l.enableHover),showLegend:a.showLegend??l.showLegend,showLabels:a.showLabels??l.showLabels,title:c?void 0:a.title,description:a.description,summary:a.summary,accessibleTable:a.accessibleTable,xLabel:c?void 0:a.xLabel,yLabel:c?void 0:a.yLabel,categoryLabel:c?void 0:a.categoryLabel,valueLabel:c?void 0:a.valueLabel,marginDefaults:As(l.marginDefaults,a.showCategoryTicks,a.orientation),compactMode:c,mobileInteraction:bs(a.mobileInteraction,{mode:s,width:a.width??u,mobileSemantics:a.mobileSemantics}),mobileSemantics:a.mobileSemantics}}function As(e,t,n){if(!1!==t)return e;const o={...e};return"horizontal"===n?o.left=Math.min(o.left,15):o.bottom=Math.min(o.bottom,15),o}function Cs(e,t){if(!function(e){return void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity}(t))return e??((...e)=>({}));const n={};return void 0!==t.stroke&&(n.stroke=t.stroke),void 0!==t.strokeWidth&&(n.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(n.opacity=t.opacity),e?(...t)=>({...e(...t)||{},...n}):(...e)=>({...n})}function Ms(e){if(null==e)return()=>{};const t="function"==typeof e?e:t=>t[e];return e=>Ls(t(e))}function Rs(e,t){const n=Ms(t??"value"),o=null==e?void 0:"function"==typeof e?e:t=>t[e];return e=>{const t=o?o(e):void 0;return{value:n(e),category:null==t?void 0:t+""}}}function Ls(e){if("number"==typeof e)return Number.isFinite(e)?e:void 0;if("string"==typeof e&&""!==e.trim()){const t=Number(e);return Number.isFinite(t)?t:void 0}}function js(e,t,n){const o=null!=e.axis?n[e.axis]:null!=e.field?t[e.field]:n.value;if(void 0!==e.eq&&o!==e.eq)return!1;if(void 0!==e.ne&&o===e.ne)return!1;if(void 0!==e.in&&!e.in.includes(o))return!1;if(void 0===e.gt&&void 0===e.gte&&void 0===e.lt&&void 0===e.lte&&void 0===e.within&&void 0===e.outside)return!0;const r=Ls(o);if(void 0===r)return!1;if(void 0!==e.gt&&e.gt>=r)return!1;if(void 0!==e.gte&&e.gte>r)return!1;if(void 0!==e.lt&&r>=e.lt)return!1;if(void 0!==e.lte&&r>e.lte)return!1;if(void 0!==e.within){const[t,n]=e.within;if(t>r||r>n)return!1}if(void 0!==e.outside){const[t,n]=e.outside;if(r>=t&&n>=r)return!1}return!0}function Ps(e,t,n){const o=e.when;return void 0===o||!0===o||!1!==o&&("function"==typeof o?o(t,n):js(o,t,n))}function Is(e,t,n){if(!t||0===t.length)return{};let o={};for(const r of t){if(!Ps(r,e,n))continue;const t="function"==typeof r.style?r.style(e,n):r.style;t&&(o={...o,...t})}return o}function Ts(e,t,n,o=e=>e){const r=e??(()=>({}));return t&&0!==t.length?(e,i)=>{const a=o(e),s={...r(e,i)};return Object.assign(s,Is(a,t,n(a,i))),s}:r}import{jsx as Ds,jsxs as zs}from"react/jsx-runtime";function Os({componentName:e,message:t,diagnosticHint:n,width:o,height:r}){return Ds("div",{role:"alert",style:{width:o,height:Math.max(r,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"},children:zs("div",{style:{textAlign:"center",maxWidth:400},children:[Ds("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"},children:e}),Ds("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5},children:t}),n&&Ds("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},children:n})]})})}import*as Ns from"react";import{jsx as Bs}from"react/jsx-runtime";var Es=class extends Ns.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){this.props.onError?.(e,t)}render(){if(this.state.error){const{fallback:e}=this.props,t=this.state.error;return"function"==typeof e?e(t):void 0!==e?e:Bs(Os,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}};import{jsx as Ws}from"react/jsx-runtime";var _s="undefined"!=typeof process&&"production"!==process.env?.NODE_ENV;function Hs({componentName:e,width:t,height:n,children:o}){return Ws(Es,{fallback:o=>Ws(Os,{componentName:e,message:o.message,width:t,height:n}),children:o})}var Fs={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #666)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},$s={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Gs(e,t,n,o){return!1===o||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?Ws("div",{style:{...Fs,width:t,height:n},children:o||"No data available"}):null}function qs(e,t,n,o){if(!e)return null;if(!1===o)return null;if(null!=o)return Ws("div",{style:{width:t,height:n,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:o});const r=Math.min(5,Math.floor(n/40)),i=Math.max(8,Math.floor(n/(3*r))),a=Math.max(6,Math.floor(n/(2.5*r))),s=Math.floor((n-(r*(i+a)-a))/2);return Ws("div",{style:{width:t,height:n,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:r},(e,n)=>Ws("div",{className:"semiotic-loading-bar",style:{...$s,position:"absolute",top:s+n*(i+a),left:Math.floor(.1*t),width:30+(37*n+13)%50+"%",height:i,opacity:.5+n%2*.2}},n))})}function Vs(e,t,n,o){if(!_s)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}`)}import{useMemo as Us}from"react";function Zs(e){const t=St(e=>e.theme.colors.selectionOpacity);return Us(()=>{if(void 0!==e||void 0!==t)return{name:e?.name??"",...e,unselectedOpacity:e?.unselectedOpacity??t}},[e,t])}import{scaleSequential as Ys}from"d3-scale";import{useState as Xs,useEffect as Qs,useMemo as Ks}from"react";import{feature as Js}from"topojson-client";var el=new Map;function tl(e){return"default"in e?e.default:e}async function nl(e){const t=el.get(e);if(t)return t;const{topology:n,objectName:o}=await async function(e){try{switch(e){case"world-110m":return{topology:tl(await import("world-atlas/countries-110m.json")),objectName:"countries"};case"world-50m":return{topology:tl(await import("world-atlas/countries-50m.json")),objectName:"countries"};case"land-110m":return{topology:tl(await import("world-atlas/land-110m.json")),objectName:"land"};case"land-50m":return{topology:tl(await import("world-atlas/land-50m.json")),objectName:"land"};default:throw Error(`Unknown reference geography: "${e}". Supported: "world-110m", "world-50m", "land-110m", "land-50m".`)}}catch(t){if(/Cannot find module|Failed to resolve|world-atlas/i.test(t instanceof Error?t.message:t+""))throw Error(`resolveReferenceGeography("${e}"): Install the optional peer dependency \`world-atlas\` (\`npm install world-atlas\`) to use built-in reference geographies, or pass GeoJSON Feature[] to \`areas\`.`,{cause:t});throw t}}(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=Js(n,n.objects[o]),i="features"in r?r.features:[r];return el.set(e,i),i}function ol(e){const t=Ks(()=>Array.isArray(e)?e:void 0,[e]),[n,o]=Xs(null);return Qs(()=>{if(e&&!Array.isArray(e)){if("string"==typeof(t=e)&&["world-110m","world-50m","land-110m","land-50m"].includes(t)){let t=!1;return o(null),nl(e).then(e=>{t||o(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".`),o(null)}else o(null)},[e]),void 0!==t?t:n}function rl(e){const{title:t,description:n,summary:o,accessibleTable:r,className:i,animate:a,axisExtent:s,autoPlaceAnnotations:l}=e,c={};return t&&(c.title=t),n&&(c.description=n),o&&(c.summary=o),void 0!==r&&(c.accessibleTable=r),i&&(c.className=i),null!=a&&(c.animate=a),void 0!==s&&(c.axisExtent=s),void 0!==l&&(c.autoPlaceAnnotations=l),c}function il(e){const{linkedHover:t,selection:n,onObservation:o,onClick:r,hoverRadius:i,hoverHighlight:a,forceHoverBehavior:s,forceClickBehavior:l,mobileInteraction:c,customHoverBehavior:u,customClickBehavior:d,linkedHoverInClickPredicate:h=!0}=e,f={};o&&(f.annotationObservationCallback=o);const p=c?.enabled?Math.max(i??30,Math.ceil((c.targetSize||44)/2),24):i;return(s||t||o||r||a)&&(f.customHoverBehavior=u),d&&(l||(h?o||r||t:o||r)||c?.enabled&&(c.tapToSelect||c.tapToLockTooltip)&&(t||a||n))&&(f.customClickBehavior=d),null!=p&&(f.hoverRadius=p),f}import{jsx as al,jsxs as sl}from"react/jsx-runtime";function ll(e){const t=Ss(e.mode,{width:e.width,height:e.height,showLegend:e.showLegend,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),n=function(){const e=ls();return e?.colors?.sequential||void 0}(),{areas:o,valueAccessor:r,styleRules:i,colorScheme:a,projection:s="equalEarth",graticule:l,fitPadding:c,zoomable:u,zoomExtent:d,onZoom:h,dragRotate:f,tileURL:p,tileAttribution:m,tileCacheSize:y,tooltip:g,areaOpacity:b=1,annotations:v,margin:x,className:w,selection:k,linkedHover:S,onObservation:A,onClick:C,chartId:M,loading:R,loadingContent:L,emptyContent:j,frameProps:P={},stroke:I,strokeWidth:T,opacity:z}=e,O=u??!!p,N=ol(o),B=fa(()=>N?Br(N):N,[N]),E=fa(()=>"function"==typeof r?r:e=>e?.properties?.[r]??e?.[r],[r]),W=a??n??"blues",_=fa(()=>{if(!B)return Ys(D(void 0)).domain([0,1]);let e=1/0,t=-1/0;for(const n of B){const o=E(n);null!=o&&isFinite(o)&&(e>o&&(e=o),o>t&&(t=o))}const n=D(W);return Ys(n).domain([Number.isFinite(e)?e:0,Number.isFinite(t)?t:1])},[B,E,W]),{activeSelectionHook:H,customHoverBehavior:F,customClickBehavior:$}=xs({selection:k,linkedHover:S,onObservation:A,onClick:C,chartType:"ChoroplethMap",chartId:M,mobileInteraction:t.mobileInteraction}),G=Zs(k),q=fa(()=>{const e=Cs(Ts(e=>{const t=E(e);return{fill:null!=t&&isFinite(t)?_(t):"#ccc",stroke:"#999",strokeWidth:.5,fillOpacity:b}},i,e=>({value:E(e)}),e=>e&&"object"==typeof e&&e.properties?{...e.properties,...e}:e),{stroke:I,strokeWidth:T,opacity:z});return H?rs(e,H,G):e},[E,_,H,G,b,I,T,z,i]),V=fa(()=>e=>{const t=e?.properties?.name||e?.properties?.NAME||e?.name||e?.NAME||"Feature",n=E(e);return sl("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12},children:[al("div",{style:{fontWeight:600},children:t}),null!=n&&al("div",{style:{opacity:.7},children:(o=n,"number"==typeof o&&isFinite(o)?Number.isInteger(o)?o.toLocaleString():o.toLocaleString(void 0,{maximumFractionDigits:2}):(o??"")+"")})]});var o},[E]),U=fa(()=>({top:10,right:10,bottom:10,left:10,...pa(x)}),[x]),Z=qs(R,t.width,t.height,L)||(B?null:qs(!0,t.width,t.height,L)),Y=Z?null:Gs(B,t.width,t.height,j);if(Array.isArray(B)&&B.length>0){const e=B[0];if(!e||"object"!=typeof e||!e.geometry)return al(Os,{componentName:"ChoroplethMap",message:"ChoroplethMap: areas must be an array of GeoJSON Features with a geometry property.",width:t.width,height:t.height})}const X={projection:s,areas:B,areaStyle:q,size:[t.width,t.height],margin:U,enableHover:!0,tooltipContent:!1===g?()=>null:!0===g?V:ei(g)||V,...null!=l&&{graticule:l},...null!=c&&{fitPadding:c},...O&&{zoomable:!0},...d&&{zoomExtent:d},...h&&{onZoom:h},...null!=f&&{dragRotate:f},...p&&{tileURL:p},...m&&{tileAttribution:m},...y&&{tileCacheSize:y},...il({linkedHover:S,selection:k,onObservation:A,onClick:C,mobileInteraction:t.mobileInteraction,customHoverBehavior:F,customClickBehavior:$,linkedHoverInClickPredicate:!1}),...v&&v.length>0&&{annotations:v},...void 0!==e.autoPlaceAnnotations&&{autoPlaceAnnotations:e.autoPlaceAnnotations},...t.title&&{title:t.title},...t.description&&{description:t.description},...t.summary&&{summary:t.summary},...void 0!==t.accessibleTable&&{accessibleTable:t.accessibleTable},...w&&{className:w},...null!=e.animate&&{animate:e.animate},...P};return Z||Y||al(Hs,{componentName:"ChoroplethMap",width:t.width,height:t.height,children:al(ha,{...X})})}ll.displayName="ChoroplethMap";import{useMemo as cl,useRef as ul,forwardRef as dl}from"react";import{useCallback as hl,useMemo as fl,useState as pl}from"react";function ml(e){const{data:t,rawData:n,colorBy:o,colorScheme:r,legendInteraction:i,legendPosition:a,selection:s,linkedHover:l,fallbackFields:c,unwrapData:u=!1,onObservation:d,chartType:h,chartId:f,showLegend:p,userMargin:m,marginDefaults:y,onClick:g,hoverHighlight:b,mobileInteraction:v,mobileSemantics:x,loading:w,loadingContent:k,emptyContent:S,width:A,height:C}=e,M=void 0===n,R=fl(()=>Br(t),[t]),[L,j]=pl([]),P=hl(e=>{j(t=>t.length===e.length&&t.every((t,n)=>t===e[n])?t:e)},[]),I="string"==typeof e.colorBy?e.colorBy:void 0,T=fl(()=>bs(v,{width:A,mobileSemantics:x}),[v,A,x]),{activeSelectionHook:D,hoverSelectionHook:z,customHoverBehavior:O,customClickBehavior:B,crosshairSourceId:E}=xs({selection:s,linkedHover:l,fallbackFields:c,unwrapData:u,onObservation:d,chartType:h,chartId:f,onClick:g,hoverHighlight:b,colorByField:I,mobileInteraction:T}),W=function(e,t){const n="object"==typeof e&&null!==e?e:void 0;if("x-position"===n?.mode)return{linkedCrosshairName:n.name||"hover",linkedCrosshairSourceId:t}}(l,E),H=function(e,t,n){const o=Ma(),r=vs();return ma(()=>{if(!t)return;const i=o??void 0,a=n??(r&&r.length>0?r:void 0)??"category10";if(0!==e.length){if("function"==typeof t){const n=Array.from(new Set(e.map(e=>t(e)+"")));if(i&&ps(i)){const e=_(n.map(e=>({_cat:e})),"_cat",a);return t=>i[t]||e(t)}return _(n.map(e=>({_cat:e})),"_cat",a)}if(i&&ps(i)){const n=_(e,t,a);return e=>i[e]||n(e)}return _(e,t,a)}if(i&&ps(i)){const e=_([{_:"a"}],"_",a);return t=>i[t]||e(t)}},[e,t,n,o,r])}(R,o,r),F=fl(()=>{if(!o)return[];const e=new Set;for(const t of R){const n="function"==typeof o?o(t):t[o];null!=n&&e.add(n+"")}return Array.from(e)},[R,o]),$=fl(()=>M&&L.length>0?L:F,[M,L,F]),G=function(e,t,n){const[o,r]=ga(null),[i,a]=ga(new Set),s=ma(()=>new Set,[]),l=ya(t=>{"highlight"===e&&r(t?t.label:null)},[e]),c=ya(t=>{"isolate"===e&&a(e=>{const o=new Set(e);return o.has(t.label)?o.delete(t.label):o.add(t.label),o.size===n.length?new Set:o})},[e,n.length]),u=ma(()=>{if(!e||"none"===e||!t)return null;const n="string"==typeof t?t:null;return"highlight"===e&&null!=o?{isActive:!0,predicate:e=>(n?e[n]:"function"==typeof t?t(e):null)===o}:"isolate"===e&&i.size>0?{isActive:!0,predicate:e=>{const o=n?e[n]:"function"==typeof t?t(e):null;return i.has(o)}}:null},[e,t,o,i]);return{highlightedCategory:"highlight"===e?o:null,isolatedCategories:"isolate"===e?i:s,onLegendHover:l,onLegendClick:c,legendSelectionHook:u}}(i,o,$),q=fl(()=>z||(G.legendSelectionHook?G.legendSelectionHook:D),[z,G.legendSelectionHook,D]),V=Zs(s),U=vs(),Z=Ma(),Y=fl(()=>{if(H)return H;if(!o||0===$.length)return;const e=Array.isArray(r)&&r.length>0||"string"==typeof r&&r.length>0?r:U&&U.length>0?U:N,t="__streamCat",n=_($.map(e=>({[t]:e})),t,e);return e=>Z?.[e]||n(e)||"#999"},[H,o,$,r,U,Z]),{legend:X,margin:Q,legendPosition:K}=ws({data:R,colorBy:o,colorScale:Y,showLegend:p,legendPosition:a,userMargin:m,defaults:y,categories:$}),J=fl(()=>{const e={};return X&&(e.legend=X,e.legendPosition=K),i&&"none"!==i&&(e.legendHoverBehavior=G.onLegendHover,e.legendClickBehavior=G.onLegendClick,e.legendHighlightedCategory=G.highlightedCategory,e.legendIsolatedCategories=G.isolatedCategories),M&&o&&(e.legendCategoryAccessor=o,e.onCategoriesChange=P),e},[X,K,i,G.onLegendHover,G.onLegendClick,G.highlightedCategory,G.isolatedCategories,M,o,P]),ee=Array.isArray(n)?Br(n):n,te=qs(w,A,C,k),ne=te?null:Gs(ee,A,C,S);return{data:R,colorScale:H,allCategories:$,legendState:G,effectiveSelectionHook:q,activeSelectionHook:D,customHoverBehavior:O,customClickBehavior:B,mobileInteraction:T,legend:X,margin:Q,legendPosition:K,earlyReturn:te||ne||null,legendBehaviorProps:J,crosshairProps:W,resolvedSelection:V}}import{useImperativeHandle as yl}from"react";function gl(e,t){const{variant:n,frameRef:o,overrides:r}=t;yl(e,()=>{const e=function(e,t){if("xy"===e){const e=t;return{push:t=>e.current?.push(t),pushMany:t=>e.current?.pushMany(t),remove:t=>e.current?.remove(t)??[],update:(t,n)=>e.current?.update(t,n)??[],clear:()=>e.current?.clear(),getData:()=>e.current?.getData()??[],getScales:()=>e.current?.getScales()??null,getCustomLayout:()=>e.current?.getCustomLayout?.()??null,getLayoutFailure:()=>e.current?.getLayoutFailure?.()??null}}if("network"===e){const e=t;return{push:t=>e.current?.push(t),pushMany:t=>e.current?.pushMany(t),remove:t=>{const n=Array.isArray(t)?t:[t],o=e.current?.getTopology()?.nodes??[],r=[];for(const t of n){const n=o.find(e=>e.id===t);n&&r.push({...n.data??{},id:t}),e.current?.removeNode(t)}return r},update:(t,n)=>(Array.isArray(t)?t:[t]).flatMap(t=>{const o=e.current?.updateNode(t,n);return o?[{...o,id:t}]:[]}),clear:()=>e.current?.clear(),getData:()=>e.current?.getTopology()?.nodes?.map(e=>e.data)??[],getCustomLayout:()=>e.current?.getCustomLayout?.()??null,getLayoutFailure:()=>e.current?.getLayoutFailure?.()??null}}if("geo-points"===e){const e=t;return{push:t=>e.current?.push(t),pushMany:t=>e.current?.pushMany(t),remove:t=>e.current?.removePoint(t)??[],update:(t,n)=>{const o=e.current?.removePoint(t)??[];for(const t of o)e.current?.push(n(t));return o},clear:()=>e.current?.clear(),getData:()=>e.current?.getData()??[],getCustomLayout:()=>e.current?.getCustomLayout?.()??null,getLayoutFailure:()=>e.current?.getLayoutFailure?.()??null}}const n=t;return{push:e=>n.current?.pushLine(e),pushMany:e=>n.current?.pushManyLines(e),remove:e=>n.current?.removeLine(e)??[],update:(e,t)=>{const o=n.current?.removeLine(e)??[];for(const e of o)n.current?.pushLine(t(e));return o},clear:()=>n.current?.clear(),getData:()=>n.current?.getLines()??[],getCustomLayout:()=>n.current?.getCustomLayout?.()??null,getLayoutFailure:()=>n.current?.getLayoutFailure?.()??null}}(n,o);return{...e,...r}},[o,r,n])}import{jsx as bl,jsxs as vl}from"react/jsx-runtime";var xl=dl(function(e,t){const n=ul(null);gl(t,{variant:"geo-points",frameRef:n});const o=Ss(e.mode,{width:e.width,height:e.height,showLegend:e.showLegend,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{points:r,xAccessor:i="lon",yAccessor:a="lat",sizeBy:s,sizeRange:l=[3,30],colorBy:c,styleRules:u,colorScheme:d,projection:h="equalEarth",graticule:f,fitPadding:p,zoomable:m,zoomExtent:y,onZoom:g,dragRotate:b,tileURL:v,tileAttribution:x,tileCacheSize:w,areas:k,areaStyle:S={fill:"#f0f0f0",stroke:"#ccc",strokeWidth:.5},tooltip:A,annotations:C,margin:M,className:R,selection:L,linkedHover:j,onObservation:P,onClick:I,chartId:T,loading:D,loadingContent:z,emptyContent:O,legendInteraction:N,legendPosition:B,frameProps:W={},stroke:_,strokeWidth:F,opacity:$}=e,G=m??!!v,q=ol(k),V=ml({data:r??Nr,rawData:r,colorBy:c,colorScheme:d,legendInteraction:N,legendPosition:B,selection:L,linkedHover:j,fallbackFields:c?["string"==typeof c?c:""]:[],unwrapData:!1,onObservation:P,onClick:I,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"ProportionalSymbolMap",chartId:T,showLegend:o.showLegend,userMargin:M,marginDefaults:{top:10,bottom:10,left:10,right:10},loading:D,loadingContent:z,emptyContent:O,width:o.width,height:o.height}),U=V.data,Z=cl(()=>{if(!s)return;const e="function"==typeof s?s:e=>e?.[s],t=U.filter(Boolean).map(t=>e(t)).filter(e=>null!=e&&isFinite(e));return 0!==t.length?ae(t):void 0},[U,s]),Y=cl(()=>{const e=Cs(Ts(e=>({fill:c?E(e,c,V.colorScale):ms,fillOpacity:.7,stroke:"#fff",strokeWidth:.5,r:s?H(e,s,l,Z):6}),u,Rs(c,s)),{stroke:_,strokeWidth:F,opacity:$});return V.effectiveSelectionHook?rs(e,V.effectiveSelectionHook,V.resolvedSelection):e},[c,V.colorScale,V.effectiveSelectionHook,V.resolvedSelection,s,l,Z,_,F,$,u]),X=cl(()=>e=>{const t=e?.name||e?.label||e?.NAME||e?.id,n="string"==typeof s?s:null,o=("function"==typeof s?s:e=>e[s])(e),r=e=>"number"==typeof e&&isFinite(e)?Number.isInteger(e)?e.toLocaleString():e.toLocaleString(void 0,{maximumFractionDigits:2}):(e??"")+"",i="string"==typeof c?c:null,a=i?e?.[i]:null;return vl("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12},children:[t&&bl("div",{style:{fontWeight:600,marginBottom:2},children:t}),n&&null!=o&&vl("div",{children:[vl("span",{style:{opacity:.7},children:[n,": "]}),r(o)]}),i&&null!=a&&vl("div",{children:[vl("span",{style:{opacity:.7},children:[i,": "]}),a+""]}),!t&&!n&&Object.entries(e).filter(([e])=>"data"!==e&&"x"!==e&&"y"!==e&&"time"!==e).slice(0,4).map(([e,t])=>vl("div",{children:[vl("span",{style:{opacity:.7},children:[e,": "]}),r(t)]},e))]})},[s,c]);if(V.earlyReturn)return V.earlyReturn;Vs("ProportionalSymbolMap",U,"xAccessor",i),Vs("ProportionalSymbolMap",U,"yAccessor",a);const Q={projection:h,...null!=r&&{points:U},xAccessor:i,yAccessor:a,pointStyle:Y,...e.pointIdAccessor&&{pointIdAccessor:e.pointIdAccessor},...q&&{areas:q,areaStyle:S},...null!=f&&{graticule:f},...null!=p&&{fitPadding:p},...G&&{zoomable:!0},...y&&{zoomExtent:y},...g&&{onZoom:g},...null!=b&&{dragRotate:b},...v&&{tileURL:v},...x&&{tileAttribution:x},...w&&{tileCacheSize:w},size:[o.width,o.height],margin:V.margin,enableHover:!0,tooltipContent:!1===A?()=>null:ei(A)||X,...V.legendBehaviorProps,...il({linkedHover:j,selection:L,onObservation:P,onClick:I,mobileInteraction:V.mobileInteraction,customHoverBehavior:V.customHoverBehavior,customClickBehavior:V.customClickBehavior,linkedHoverInClickPredicate:!1}),...C&&C.length>0&&{annotations:C},...void 0!==e.autoPlaceAnnotations&&{autoPlaceAnnotations:e.autoPlaceAnnotations},...o.title&&{title:o.title},...o.description&&{description:o.description},...o.summary&&{summary:o.summary},...void 0!==o.accessibleTable&&{accessibleTable:o.accessibleTable},...R&&{className:R},...null!=e.animate&&{animate:e.animate},...W};return bl(Hs,{componentName:"ProportionalSymbolMap",width:o.width,height:o.height,children:bl(ha,{ref:n,...Q})})});xl.displayName="ProportionalSymbolMap";import{useMemo as wl,useCallback as kl,useRef as Sl,forwardRef as Al}from"react";import{scaleLinear as Cl}from"d3-scale";import{jsx as Ml,jsxs as Rl}from"react/jsx-runtime";var Ll="__semiotic_x",jl="__semiotic_y",Pl=Al(function(e,t){const n=Ss(e.mode,{width:e.width,height:e.height,showLegend:e.showLegend,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{flows:o,nodes:r,nodeIdAccessor:i="id",xAccessor:a="lon",yAccessor:s="lat",valueAccessor:l="value",projection:c="equalEarth",graticule:u,fitPadding:d,zoomable:h,zoomExtent:f,onZoom:p,dragRotate:m,tileURL:y,tileAttribution:g,tileCacheSize:b,lineType:v="geo",flowStyle:x="basic",areas:w,areaStyle:k={fill:"#f0f0f0",stroke:"#ccc",strokeWidth:.5},edgeColorBy:S,edgeOpacity:A=.6,edgeWidthRange:C=[1,8],edgeLinecap:M="round",colorScheme:R,showParticles:L,particleStyle:j,tooltip:P,annotations:I,margin:T,className:D,selection:z,linkedHover:O,onObservation:N,onClick:B,chartId:W,loading:_,loadingContent:H,emptyContent:F,frameProps:$={},legendInteraction:G,legendPosition:q,stroke:V,strokeWidth:U,opacity:Z,lineIdAccessor:Y}=e,X=h??!!y,Q=ol(w),K=wl(()=>Br(r),[r]),J=ml({data:o??Nr,rawData:o,colorBy:S,colorScheme:R,legendInteraction:G,legendPosition:q,selection:z,linkedHover:O,fallbackFields:S?["string"==typeof S?S:""]:[],unwrapData:!1,onObservation:N,onClick:B,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"FlowMap",chartId:W,showLegend:n.showLegend,userMargin:T,marginDefaults:{top:10,bottom:10,left:10,right:10},loading:_,loadingContent:H,emptyContent:F,width:n.width,height:n.height}),ee=J.data,te=os(O),ne=Qa({name:te?.name||"hover",fields:te?.fields||[]}),oe=Jt(e=>e.pushObservation),re=wl(()=>{const e=new Map;for(const t of K)e.set(t[i]+"",t);return e},[K,i]),ie=Sl(null),se=Sl(re);se.current=re;const le=Sl(a);le.current=a;const ce=Sl(s);ce.current=s;const ue=kl(e=>{if(!e||"object"!=typeof e||null==e.source||null==e.target)return null;const t=se.current,n=t.get(e.source+""),o=t.get(e.target+"");if(!n||!o)return null;const r="function"==typeof le.current?le.current:e=>e[le.current],i="function"==typeof ce.current?ce.current:e=>e[ce.current];return{...e,coordinates:[{[Ll]:r(n),[jl]:i(n)},{[Ll]:r(o),[jl]:i(o)}]}},[]);gl(t,{variant:"geo-lines",frameRef:ie,overrides:{push:e=>{const t=ue(e);t&&ie.current?.pushLine(t)},pushMany:e=>{const t=[];for(const n of e){const e=ue(n);e&&t.push(e)}t.length>0&&ie.current?.pushManyLines(t)}}});const de=wl(()=>{const e=new Map;for(const t of ee)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},[ee]),he=kl(e=>{if(O)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"point"===e.type){const e=de.get(t[i]+"");e&&ne.onHover(e)}else ne.onHover(t)}else ne.onHover(null);if(N||oe){const t={timestamp:Date.now(),chartType:"FlowMap",chartId:W};if(e){let n=e.data||e.datum||e;Array.isArray(n)&&(n=n[0]);const o={...t,type:"hover",datum:n||{},x:e.x??0,y:e.y??0};N&&N(o),oe&&oe(o)}else{const e={...t,type:"hover-end"};N&&N(e),oe&&oe(e)}}},[O,ne,i,de,N,W,oe]),fe=J.customClickBehavior,pe=wl(()=>{const e="function"==typeof a?a:e=>e[a],t="function"==typeof s?s:e=>e[s];return ee.map(n=>{if(!n||"object"!=typeof n||null==n.source||null==n.target)return null;const o=re.get(n.source+""),r=re.get(n.target+"");return o&&r?{...n,coordinates:[{[Ll]:e(o),[jl]:t(o)},{[Ll]:e(r),[jl]:t(r)}]}:null}).filter(Boolean)},[ee,re,a,s]),me=wl(()=>{const e="function"==typeof a?a:e=>e[a];return t=>null!=t&&"object"==typeof t&&Ll in t?t[Ll]:e(t)},[a]),ye=wl(()=>{const e="function"==typeof s?s:e=>e[s];return t=>null!=t&&"object"==typeof t&&jl in t?t[jl]:e(t)},[s]),ge=wl(()=>{const e=ee.filter(e=>e&&"object"==typeof e).map(e=>e[l]??0).filter(e=>isFinite(e));return 0===e.length?()=>C[0]:Cl().domain(ae(e)).range(C)},[ee,l,C]),be=wl(()=>e=>({stroke:S?E(e,S,J.colorScale):ms,strokeWidth:ge(e[l]??0),strokeLinecap:M,opacity:A}),[S,J.colorScale,ge,l,A,M]),ve=wl(()=>{const e=Cs(be,{stroke:V,strokeWidth:U,opacity:Z});if(!J.effectiveSelectionHook)return e;const t={...J.resolvedSelection?.unselectedStyle||{},fillOpacity:0};return rs(e,J.effectiveSelectionHook,{...J.resolvedSelection||{},unselectedStyle:t})},[be,J.effectiveSelectionHook,J.resolvedSelection,V,U,Z]),xe=wl(()=>Cs(()=>({fill:"#333",r:5,fillOpacity:.8}),{stroke:V,strokeWidth:U,opacity:Z}),[V,U,Z]),we=wl(()=>e=>{if(e?.geometry||e?.properties||e?.data?.geometry){const t=e?.properties?.name||e?.properties?.NAME||e?.name||e?.NAME||e?.data?.properties?.name||e?.data?.properties?.NAME;if(t)return Ml("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12},children:Ml("div",{style:{fontWeight:600},children:t})})}if(null!=e?.source&&null!=e?.target){const t=e[l];return Rl("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12},children:[Rl("div",{style:{fontWeight:600},children:[e.source," → ",e.target]}),null!=t&&Ml("div",{style:{opacity:.7},children:"number"==typeof t?t.toLocaleString():t})]})}const t=e?.name||e?.label||e?.[i];return null!=t?Ml("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12},children:Ml("div",{style:{fontWeight:600},children:t})}):null},[l,i]);if(J.earlyReturn)return J.earlyReturn;const ke={projection:c,...null!=o&&{lines:pe},points:K,xAccessor:me,yAccessor:ye,lineDataAccessor:"coordinates",...null!=Y&&{lineIdAccessor:Y},lineType:v,flowStyle:x,lineStyle:ve,pointStyle:xe,...Q&&{areas:Q,areaStyle:k},...null!=u&&{graticule:u},...null!=d&&{fitPadding:d},...X&&{zoomable:!0},...f&&{zoomExtent:f},...p&&{onZoom:p},...null!=m&&{dragRotate:m},...L&&{showParticles:L},...j&&{particleStyle:j},...y&&{tileURL:y},...g&&{tileAttribution:g},...b&&{tileCacheSize:b},size:[n.width,n.height],margin:J.margin,enableHover:!0,tooltipContent:!1===P?()=>null:ei(P)||we,...J.legendBehaviorProps,...il({linkedHover:O,selection:z,onObservation:N,onClick:B,mobileInteraction:J.mobileInteraction,customHoverBehavior:he,customClickBehavior:fe,linkedHoverInClickPredicate:!1}),...I&&I.length>0&&{annotations:I},...void 0!==e.autoPlaceAnnotations&&{autoPlaceAnnotations:e.autoPlaceAnnotations},...n.title&&{title:n.title},...n.description&&{description:n.description},...n.summary&&{summary:n.summary},...void 0!==n.accessibleTable&&{accessibleTable:n.accessibleTable},...D&&{className:D},...null!=e.animate&&{animate:e.animate},...$};return Ml(Hs,{componentName:"FlowMap",width:n.width,height:n.height,children:Ml(ha,{ref:ie,...ke})})});Pl.displayName="FlowMap";import{useMemo as Il,useRef as Tl,useState as Dl,useEffect as zl,useCallback as Ol,forwardRef as Nl}from"react";import{jsx as Bl,jsxs as El}from"react/jsx-runtime";var Wl=Nl(function(e,t){const n=Ss(e.mode,{width:e.width,height:e.height,showLegend:e.showLegend,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{points:o,lines:r,xAccessor:i="lon",yAccessor:a="lat",nodeIdAccessor:s="id",center:l,costAccessor:c,strength:u=1,lineMode:d="straight",projection:h="mercator",graticule:f,fitPadding:p,zoomable:m,zoomExtent:y,onZoom:g,dragRotate:b,tileURL:v,tileAttribution:x,tileCacheSize:w,transition:k,colorBy:S,styleRules:A,colorScheme:C,pointRadius:M=5,tooltip:R,showRings:L=!0,ringStyle:j,showNorth:P=!0,costLabel:I,annotations:T,margin:D,className:z,selection:O,linkedHover:N,onObservation:B,onClick:W,chartId:_,loading:H,loadingContent:F,emptyContent:$,legendPosition:G,frameProps:q={},stroke:V,strokeWidth:U,opacity:Z}=e,Y=m??!!v,X=Il(()=>Br(o),[o]),Q=ml({data:X,rawData:o,colorBy:S,colorScheme:C,legendInteraction:void 0,legendPosition:G,selection:O,linkedHover:N,fallbackFields:S?["string"==typeof S?S:""]:[],unwrapData:!1,onObservation:B,onClick:W,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"DistanceCartogram",chartId:_,showLegend:n.showLegend,userMargin:D,marginDefaults:{top:10,bottom:10,left:10,right:10},loading:H,loadingContent:F,emptyContent:$,width:n.width,height:n.height}),K=Il(()=>{const e=Cs(Ts(e=>({fill:S?E(e,S,Q.colorScale):ms,fillOpacity:.8,stroke:"#fff",strokeWidth:1,r:M}),A,Rs(S)),{stroke:V,strokeWidth:U,opacity:Z});return Q.effectiveSelectionHook?rs(e,Q.effectiveSelectionHook,Q.resolvedSelection):e},[S,Q.colorScale,Q.effectiveSelectionHook,Q.resolvedSelection,M,V,U,Z,A]),J=Il(()=>({center:l,centerAccessor:s,costAccessor:c,strength:u,lineMode:d}),[l,s,c,u,d]),ee=Il(()=>{if(!r)return;const e="function"==typeof i?i:e=>e[i],t="function"==typeof a?a:e=>e[a],n=new Map;for(const e of X)n.set(e[s]+"",e);return r.map(o=>{if(o.coordinates)return o;const r=n.get(o.source+""),s=n.get(o.target+"");return r&&s?{...o,coordinates:[{[i]:e(r),[a]:t(r)},{[i]:e(s),[a]:t(s)}]}:null}).filter(Boolean)},[r,X,i,a,s]),te=Il(()=>e=>{const t=("function"==typeof c?c:e=>e[c])(e);return El("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12},children:[Bl("div",{style:{fontWeight:600},children:e[s]||e.name||e.id||"Point"}),null!=t&&El("div",{style:{opacity:.7},children:["Cost: ","number"==typeof t?t.toFixed(1):t]})]})},[c,s]),ne=Tl(null);gl(t,{variant:"geo-points",frameRef:ne});const[oe,re]=Dl(null),ie=Ol(()=>{const e=ne.current?.getCartogramLayout?.();e&&re(t=>t&&t.cx===e.cx&&t.cy===e.cy&&t.maxCost===e.maxCost&&t.availableRadius===e.availableRadius?t:e)},[]);zl(()=>{const e=requestAnimationFrame(ie);return()=>cancelAnimationFrame(e)},[ie,u,l,n.width,n.height,X]);const ae=Il(()=>{if(!L||!oe)return[];const{maxCost:e}=oe;if(0>=e)return[];if(Array.isArray(L))return L.filter(t=>t>0&&e>=t);const t="number"==typeof L?L: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},[L,oe]),se=Il(()=>{if(!oe)return q.foregroundGraphics||null;const{cx:e,cy:t,maxCost:n,availableRadius:o}=oe,r={stroke:"#999",strokeWidth:.8,strokeDasharray:"4,3",labelColor:"#777",labelSize:10,...j},i=Q.margin.left??10,a=Q.margin.top??10;return El("g",{children:[ae.map(s=>{const l=s/n*o;return El("g",{children:[Bl("circle",{cx:e+i,cy:t+a,r:l,fill:"none",stroke:r.stroke,strokeWidth:r.strokeWidth,strokeDasharray:r.strokeDasharray,opacity:.5}),El("text",{x:e+i+l+3,y:t+a-2,fontSize:r.labelSize,fill:r.labelColor,fontFamily:"system-ui, sans-serif",children:[s,I?" "+I:""]})]},s)}),P&&El("g",{transform:`translate(${i+24}, ${a+24})`,children:[Bl("circle",{r:16,fill:"white",fillOpacity:.85,stroke:"#bbb",strokeWidth:.8}),Bl("path",{d:"M0,-11 L3,-3 L1,-4 L1,7 L-1,7 L-1,-4 L-3,-3 Z",fill:"#555",stroke:"none"}),Bl("text",{y:-12,textAnchor:"middle",fontSize:7,fontWeight:700,fill:"#555",fontFamily:"system-ui, sans-serif",children:"N"}),Bl("line",{x1:11,y1:0,x2:13,y2:0,stroke:"#bbb",strokeWidth:.8}),Bl("line",{x1:-11,y1:0,x2:-13,y2:0,stroke:"#bbb",strokeWidth:.8}),Bl("line",{x1:0,y1:11,x2:0,y2:13,stroke:"#bbb",strokeWidth:.8})]}),q.foregroundGraphics]})},[oe,ae,P,I,j,Q.margin,q.foregroundGraphics]);if(Q.earlyReturn)return Q.earlyReturn;Vs("DistanceCartogram",X,"xAccessor",i),Vs("DistanceCartogram",X,"yAccessor",a);const le={projection:h,...null!=o&&{points:X},...ee&&{lines:ee,lineDataAccessor:"coordinates"},xAccessor:i,yAccessor:a,pointIdAccessor:s,pointStyle:K,projectionTransform:J,...k&&{transition:{duration:k}},...null!=f&&{graticule:f},...null!=p&&{fitPadding:p},...Y&&{zoomable:!0},...y&&{zoomExtent:y},...g&&{onZoom:g},...null!=b&&{dragRotate:b},...v&&{tileURL:v},...x&&{tileAttribution:x},...w&&{tileCacheSize:w},size:[n.width,n.height],margin:Q.margin,enableHover:!0,tooltipContent:!1===R?()=>null:ei(R)||te,...Q.legendBehaviorProps,...il({linkedHover:N,selection:O,onObservation:B,onClick:W,mobileInteraction:Q.mobileInteraction,customHoverBehavior:Q.customHoverBehavior,customClickBehavior:Q.customClickBehavior,linkedHoverInClickPredicate:!1}),...T&&T.length>0&&{annotations:T},...void 0!==e.autoPlaceAnnotations&&{autoPlaceAnnotations:e.autoPlaceAnnotations},...n.title&&{title:n.title},...n.description&&{description:n.description},...n.summary&&{summary:n.summary},...void 0!==n.accessibleTable&&{accessibleTable:n.accessibleTable},...z&&{className:z},...null!=e.animate&&{animate:e.animate},...q,foregroundGraphics:se};return Bl(Hs,{componentName:"DistanceCartogram",width:n.width,height:n.height,children:Bl(ha,{ref:ne,...le})})});Wl.displayName="DistanceCartogram";import{forwardRef as _l,useMemo as Hl}from"react";import{useMemo as Fl,useRef as $l}from"react";import{jsx as Gl}from"react/jsx-runtime";var ql=_l(function(e,t){const{points:n,areas:o,lines:r,layout:i,layoutConfig:a,onLayoutError:s,projection:l="equirectangular",xAccessor:c="lon",yAccessor:u="lat",lineDataAccessor:d,colorBy:h,colorScheme:f,tooltip:p,annotations:m,margin:y,selection:g,linkedHover:b,onObservation:v,onClick:x,chartId:w,loading:k,loadingContent:S,emptyContent:A,className:C,frameProps:M={}}=e,{frameRef:R,resolved:L,normalizedMargin:j}=function(e){const t=$l(null);return gl(e.imperativeRef,{variant:e.imperativeVariant,frameRef:t}),{frameRef:t,resolved:Ss(e.mode,{width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,xLabel:e.xLabel,yLabel:e.yLabel,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),normalizedMargin:Fl(()=>pa(e.margin),[e.margin])}}({imperativeRef:t,imperativeVariant:"geo-points",margin:y,width:e.width,height:e.height,enableHover:e.enableHover,title:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,mode:e.mode,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),P=Hl(()=>Br(n),[n]),I=Hl(()=>Br(o),[o]),T=Hl(()=>Br(r),[r]),D=Hl(()=>[...P,...T,...I],[P,T,I]),z=ml({data:D,rawData:void 0!==n||void 0!==r||void 0!==o?D:void 0,colorBy:h,colorScheme:f,legendInteraction:void 0,selection:g,linkedHover:b,fallbackFields:"string"==typeof h?[h]:[],unwrapData:!1,onObservation:v,onClick:x,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,chartType:"GeoCustomChart",chartId:w,showLegend:!1,userMargin:j,marginDefaults:L.marginDefaults,loading:k,loadingContent:S,emptyContent:A,width:L.width,height:L.height}),O=z.effectiveSelectionHook,N=Hl(()=>O?.isActive?{isActive:!0,predicate:O.predicate}:null,[O?.isActive,O?.predicate]);if(z.earlyReturn)return z.earlyReturn;const{width:B,height:E,enableHover:W,title:_,description:H,summary:F,accessibleTable:$}=L,G=ei(p),q={projection:l,...null!=n&&{points:P},...null!=o&&{areas:I},...null!=r&&{lines:T},xAccessor:c,yAccessor:u,...null!=d&&{lineDataAccessor:d},customLayout:i,layoutConfig:a,onLayoutError:s,layoutSelection:N,colorBy:h,colorScheme:f,size:[B,E],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:z.margin,enableHover:W,...rl({title:_,description:H,summary:F,accessibleTable:$,className:C,animate:e.animate,autoPlaceAnnotations:e.autoPlaceAnnotations}),...!1===p?{tooltipContent:()=>null}:G?{tooltipContent:G}:{},...il({linkedHover:b,selection:g,onObservation:v,onClick:x,hoverHighlight:!1,mobileInteraction:z.mobileInteraction,customHoverBehavior:z.customHoverBehavior,customClickBehavior:z.customClickBehavior,linkedHoverInClickPredicate:!1}),...m&&m.length>0&&{annotations:m},...M};return Gl(Hs,{componentName:"GeoCustomChart",width:B,height:E,children:Gl(ha,{ref:R,...q})})});ql.displayName="GeoCustomChart";var Vl={fill:"rgba(0,0,0,0)",stroke:"rgba(0,0,0,0)",opacity:0},Ul=8;function Zl(e){const t=function(e){return null==e?void 0:e+""}(e.id);return{type:"point",x:e.x,y:e.y,r:e.r??8,style:{...Vl},datum:e.datum,pointId:t,_transitionKey:t}}function Yl(e){return Zl(e)}function Xl(e){const[[t,n],[o,r]]=e.bounds;return{type:"geoarea",pathData:e.pathData,centroid:e.centroid,bounds:e.bounds,screenArea:e.screenArea??Math.abs((o-t)*(r-n)),style:{...Vl},datum:e.datum,group:e.group,interactive:!0}}function Ql(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&&"object"==typeof n?n[e]:void 0;return(n??"")+""})(e),n=i.get(t);return n?{...e,properties:{...e.properties,...n}}:e})}export{ll as ChoroplethMap,Ul as DEFAULT_HIT_RADIUS,Wl as DistanceCartogram,Pl as FlowMap,ql as GeoCustomChart,xl as ProportionalSymbolMap,ha as StreamGeoFrame,Ts as composeStyleRules,Xl as geoAreaHitTarget,Yl as geoHitTarget,qe as glyphExtent,Ge as glyphPlacement,Zn as hatchFillId,Xn as hatchPatternDef,Zl as hitTargetPoint,Vn as isHatchFill,Rs as makeNodeRuleContext,Ms as makeRuleValueResolver,js as matchesThreshold,Ql as mergeData,nl as resolveReferenceGeography,ds as resolveResponsiveRules,Is as resolveStyleRules,Qn as resolveSvgFill,us as responsiveRuleMatches,Ps as ruleMatches};
2
+ import{DEFAULT_HIT_RADIUS as e,geoAreaHitTarget as t,geoHitTarget as o,hitTargetPoint as i}from"./chunk-chunk-J3XWETBJ.module.min.js";import{GeoCustomChart as n,StreamGeoFrame_default as r}from"./chunk-chunk-OBQRFTIL.module.min.js";import{mergeShapeStyle as a,normalizePartialMargin as l,useChartSetup as s,useFrameImperativeHandle as c,useResolvedSelection as m}from"./chunk-chunk-I6C3KR5H.module.min.js";import"./chunk-chunk-XQYVEKEJ.module.min.js";import"./chunk-chunk-M7VYYHCE.module.min.js";import"./chunk-chunk-OQTLSTGI.module.min.js";import{buildCustomBehaviorProps as d}from"./chunk-chunk-A63CTACR.module.min.js";import"./chunk-chunk-5UKL5W76.module.min.js";import{composeStyleRules as u,makeNodeRuleContext as h,makeRuleValueResolver as p,matchesThreshold as f,resolveStyleRules as g,ruleMatches as y}from"./chunk-chunk-EMO5NUGE.module.min.js";import"./chunk-chunk-SANERMIZ.module.min.js";import{DEFAULT_COLOR as b,EMPTY_ARRAY as v,filterSparseArray as k,getColor as w,getSequentialInterpolator as S,getSize as C,hatchFillId as A,hatchPatternDef as x,isHatchFill as j,normalizeLinkedHover as R,normalizeTooltip as I,resolveResponsiveRules as P,resolveSvgFill as M,responsiveRuleMatches as H,useChartMode as L,useChartSelection as N,useLinkedHover as z,useObservationSelector as T,useThemeSequential as B,wrapStyleWithSelection as E}from"./chunk-chunk-6HSGDMTA.module.min.js";import{getMinMax as W}from"./chunk-chunk-JJ2OOIET.module.min.js";import"./chunk-chunk-WCX6U47H.module.min.js";import{glyphExtent as O,glyphPlacement as F}from"./chunk-chunk-KTWEBFMX.module.min.js";import{ChartError as D,SafeRender as U,renderEmptyState as Z,renderLoadingState as G,warnMissingField as $}from"./chunk-chunk-ZCNBUZPL.module.min.js";import"./chunk-chunk-YHNZCPOZ.module.min.js";import{useMemo as J}from"react";import{scaleSequential as _}from"d3-scale";import{useState as K,useEffect as q,useMemo as X}from"react";import{feature as Y}from"topojson-client";var Q=new Map;function V(e){return"default"in e?e.default:e}async function ee(e){const t=Q.get(e);if(t)return t;const{topology:o,objectName:i}=await async function(e){try{switch(e){case"world-110m":return{topology:V(await import("world-atlas/countries-110m.json")),objectName:"countries"};case"world-50m":return{topology:V(await import("world-atlas/countries-50m.json")),objectName:"countries"};case"land-110m":return{topology:V(await import("world-atlas/land-110m.json")),objectName:"land"};case"land-50m":return{topology:V(await import("world-atlas/land-50m.json")),objectName:"land"};default:throw Error(`Unknown reference geography: "${e}". Supported: "world-110m", "world-50m", "land-110m", "land-50m".`)}}catch(t){if(/Cannot find module|Failed to resolve|world-atlas/i.test(t instanceof Error?t.message:t+""))throw Error(`resolveReferenceGeography("${e}"): Install the optional peer dependency \`world-atlas\` (\`npm install world-atlas\`) to use built-in reference geographies, or pass GeoJSON Feature[] to \`areas\`.`,{cause:t});throw t}}(e);if(!o||!o.objects)throw Error(`resolveReferenceGeography("${e}"): Failed to load topology. Got ${typeof o} with keys: ${o?Object.keys(o).join(", "):"none"}`);const n=Y(o,o.objects[i]),r="features"in n?n.features:[n];return Q.set(e,r),r}function te(e){const t=X(()=>Array.isArray(e)?e:void 0,[e]),[o,i]=K(null);return q(()=>{if(e&&!Array.isArray(e)){if("string"==typeof(t=e)&&["world-110m","world-50m","land-110m","land-50m"].includes(t)){let t=!1;return i(null),ee(e).then(e=>{t||i(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".`),i(null)}else i(null)},[e]),void 0!==t?t:o}import{jsx as oe,jsxs as ie}from"react/jsx-runtime";function ne(e){const t=L(e.mode,{width:e.width,height:e.height,showLegend:e.showLegend,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),o=B(),{areas:i,valueAccessor:n,styleRules:s,colorScheme:c,projection:h="equalEarth",graticule:p,fitPadding:f,zoomable:g,zoomExtent:y,onZoom:b,dragRotate:v,tileURL:w,tileAttribution:C,tileCacheSize:A,tooltip:x,areaOpacity:j=1,annotations:R,margin:P,className:M,selection:H,linkedHover:z,onObservation:T,onClick:W,chartId:O,loading:F,loadingContent:$,emptyContent:K,frameProps:q={},stroke:X,strokeWidth:Y,opacity:Q}=e,V=g??!!w,ee=te(i),ne=J(()=>ee?k(ee):ee,[ee]),re=J(()=>"function"==typeof n?n:e=>e?.properties?.[n]??e?.[n],[n]),ae=c??o??"blues",le=J(()=>{if(!ne)return _(S(void 0)).domain([0,1]);let e=1/0,t=-1/0;for(const o of ne){const i=re(o);null!=i&&isFinite(i)&&(e>i&&(e=i),i>t&&(t=i))}const o=S(ae);return _(o).domain([Number.isFinite(e)?e:0,Number.isFinite(t)?t:1])},[ne,re,ae]),{activeSelectionHook:se,customHoverBehavior:ce,customClickBehavior:me}=N({selection:H,linkedHover:z,onObservation:T,onClick:W,chartType:"ChoroplethMap",chartId:O,mobileInteraction:t.mobileInteraction}),de=m(H),ue=J(()=>{const e=u(e=>{const t=re(e);return{fill:null!=t&&isFinite(t)?le(t):"#ccc",stroke:"#999",strokeWidth:.5,fillOpacity:j}},s,e=>({value:re(e)}),e=>e&&"object"==typeof e&&e.properties?{...e.properties,...e}:e),t=a(e,{stroke:X,strokeWidth:Y,opacity:Q});return se?E(t,se,de):t},[re,le,se,de,j,X,Y,Q,s]),he=J(()=>e=>{const t=e?.properties?.name||e?.properties?.NAME||e?.name||e?.NAME||"Feature",o=re(e);return ie("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12},children:[oe("div",{style:{fontWeight:600},children:t}),null!=o&&oe("div",{style:{opacity:.7},children:(i=o,"number"==typeof i&&isFinite(i)?Number.isInteger(i)?i.toLocaleString():i.toLocaleString(void 0,{maximumFractionDigits:2}):(i??"")+"")})]});var i},[re]),pe=J(()=>({top:10,right:10,bottom:10,left:10,...l(P)}),[P]),fe=G(F,t.width,t.height,$)||(ne?null:G(!0,t.width,t.height,$)),ge=fe?null:Z(ne,t.width,t.height,K);if(Array.isArray(ne)&&ne.length>0){const e=ne[0];if(!e||"object"!=typeof e||!e.geometry)return oe(D,{componentName:"ChoroplethMap",message:"ChoroplethMap: areas must be an array of GeoJSON Features with a geometry property.",width:t.width,height:t.height})}const ye={projection:h,areas:ne,areaStyle:ue,size:[t.width,t.height],margin:pe,enableHover:!0,tooltipContent:!1===x?()=>null:!0===x?he:I(x)||he,...null!=p&&{graticule:p},...null!=f&&{fitPadding:f},...V&&{zoomable:!0},...y&&{zoomExtent:y},...b&&{onZoom:b},...null!=v&&{dragRotate:v},...w&&{tileURL:w},...C&&{tileAttribution:C},...A&&{tileCacheSize:A},...d({linkedHover:z,selection:H,onObservation:T,onClick:W,mobileInteraction:t.mobileInteraction,customHoverBehavior:ce,customClickBehavior:me,linkedHoverInClickPredicate:!1}),...R&&R.length>0&&{annotations:R},...void 0!==e.autoPlaceAnnotations&&{autoPlaceAnnotations:e.autoPlaceAnnotations},...t.title&&{title:t.title},...t.description&&{description:t.description},...t.summary&&{summary:t.summary},...void 0!==t.accessibleTable&&{accessibleTable:t.accessibleTable},...M&&{className:M},...null!=e.animate&&{animate:e.animate},...q};return fe||ge||oe(U,{componentName:"ChoroplethMap",width:t.width,height:t.height,children:oe(r,{...ye})})}ne.displayName="ChoroplethMap";import{useMemo as re,useRef as ae,forwardRef as le}from"react";var se={fill:"#f0f0f0",stroke:"#ccc",strokeWidth:.5};import{jsx as ce,jsxs as me}from"react/jsx-runtime";var de=le(function(e,t){const o=ae(null);c(t,{variant:"geo-points",frameRef:o});const i=L(e.mode,{width:e.width,height:e.height,showLegend:e.showLegend,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{points:n,xAccessor:l="lon",yAccessor:m="lat",sizeBy:p,sizeRange:f=[3,30],colorBy:g,styleRules:y,colorScheme:k,projection:S="equalEarth",graticule:A,fitPadding:x,zoomable:j,zoomExtent:R,onZoom:P,dragRotate:M,tileURL:H,tileAttribution:N,tileCacheSize:z,areas:T,areaStyle:B=se,tooltip:O,annotations:F,margin:D,className:Z,selection:G,linkedHover:J,onObservation:_,onClick:K,chartId:q,loading:X,loadingContent:Y,emptyContent:Q,legendInteraction:V,legendPosition:ee,frameProps:oe={},stroke:ie,strokeWidth:ne,opacity:le}=e,de=j??!!H,ue=te(T),he=s({data:n??v,rawData:n,colorBy:g,colorScheme:k,legendInteraction:V,legendPosition:ee,selection:G,linkedHover:J,fallbackFields:g?["string"==typeof g?g:""]:[],unwrapData:!1,onObservation:_,onClick:K,mobileInteraction:i.mobileInteraction,mobileSemantics:i.mobileSemantics,chartType:"ProportionalSymbolMap",chartId:q,showLegend:i.showLegend,userMargin:D,marginDefaults:{top:10,bottom:10,left:10,right:10},loading:X,loadingContent:Y,emptyContent:Q,width:i.width,height:i.height}),pe=he.data,fe=re(()=>{if(!p)return;const e="function"==typeof p?p:e=>e?.[p],t=pe.filter(Boolean).map(t=>e(t)).filter(e=>null!=e&&isFinite(e));return 0!==t.length?W(t):void 0},[pe,p]),ge=re(()=>{const e=u(e=>({fill:g?w(e,g,he.colorScale):b,fillOpacity:.7,stroke:"#fff",strokeWidth:.5,r:p?C(e,p,f,fe):6}),y,h(g,p)),t=a(e,{stroke:ie,strokeWidth:ne,opacity:le});return he.effectiveSelectionHook?E(t,he.effectiveSelectionHook,he.resolvedSelection):t},[g,he.colorScale,he.effectiveSelectionHook,he.resolvedSelection,p,f,fe,ie,ne,le,y]),ye=re(()=>e=>{const t=e?.name||e?.label||e?.NAME||e?.id,o="string"==typeof p?p:null,i=("function"==typeof p?p:e=>e[p])(e),n=e=>"number"==typeof e&&isFinite(e)?Number.isInteger(e)?e.toLocaleString():e.toLocaleString(void 0,{maximumFractionDigits:2}):(e??"")+"",r="string"==typeof g?g:null,a=r?e?.[r]:null;return me("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12},children:[t&&ce("div",{style:{fontWeight:600,marginBottom:2},children:t}),o&&null!=i&&me("div",{children:[me("span",{style:{opacity:.7},children:[o,": "]}),n(i)]}),r&&null!=a&&me("div",{children:[me("span",{style:{opacity:.7},children:[r,": "]}),a+""]}),!t&&!o&&Object.entries(e).filter(([e])=>"data"!==e&&"x"!==e&&"y"!==e&&"time"!==e).slice(0,4).map(([e,t])=>me("div",{children:[me("span",{style:{opacity:.7},children:[e,": "]}),n(t)]},e))]})},[p,g]);if(he.earlyReturn)return he.earlyReturn;$("ProportionalSymbolMap",pe,"xAccessor",l),$("ProportionalSymbolMap",pe,"yAccessor",m);const be={projection:S,...null!=n&&{points:pe},xAccessor:l,yAccessor:m,pointStyle:ge,...e.pointIdAccessor&&{pointIdAccessor:e.pointIdAccessor},...ue&&{areas:ue,areaStyle:B},...null!=A&&{graticule:A},...null!=x&&{fitPadding:x},...de&&{zoomable:!0},...R&&{zoomExtent:R},...P&&{onZoom:P},...null!=M&&{dragRotate:M},...H&&{tileURL:H},...N&&{tileAttribution:N},...z&&{tileCacheSize:z},size:[i.width,i.height],margin:he.margin,enableHover:!0,tooltipContent:!1===O?()=>null:I(O)||ye,...he.legendBehaviorProps,...d({linkedHover:J,selection:G,onObservation:_,onClick:K,mobileInteraction:he.mobileInteraction,customHoverBehavior:he.customHoverBehavior,customClickBehavior:he.customClickBehavior,linkedHoverInClickPredicate:!1}),...F&&F.length>0&&{annotations:F},...void 0!==e.autoPlaceAnnotations&&{autoPlaceAnnotations:e.autoPlaceAnnotations},...i.title&&{title:i.title},...i.description&&{description:i.description},...i.summary&&{summary:i.summary},...void 0!==i.accessibleTable&&{accessibleTable:i.accessibleTable},...Z&&{className:Z},...null!=e.animate&&{animate:e.animate},...oe};return ce(U,{componentName:"ProportionalSymbolMap",width:i.width,height:i.height,children:ce(r,{ref:o,...be})})});de.displayName="ProportionalSymbolMap";import{useMemo as ue,useCallback as he,useRef as pe,forwardRef as fe}from"react";import{scaleLinear as ge}from"d3-scale";import{jsx as ye,jsxs as be}from"react/jsx-runtime";var ve="__semiotic_x",ke="__semiotic_y",we=fe(function(e,t){const o=L(e.mode,{width:e.width,height:e.height,showLegend:e.showLegend,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{flows:i,nodes:n,nodeIdAccessor:l="id",xAccessor:m="lon",yAccessor:u="lat",valueAccessor:h="value",projection:p="equalEarth",graticule:f,fitPadding:g,zoomable:y,zoomExtent:S,onZoom:C,dragRotate:A,tileURL:x,tileAttribution:j,tileCacheSize:P,lineType:M="geo",flowStyle:H="basic",areas:N,areaStyle:B=se,edgeColorBy:O,edgeOpacity:F=.6,edgeWidthRange:D=[1,8],edgeLinecap:Z="round",colorScheme:G,showParticles:$,particleStyle:J,tooltip:_,annotations:K,margin:q,className:X,selection:Y,linkedHover:Q,onObservation:V,onClick:ee,chartId:oe,loading:ie,loadingContent:ne,emptyContent:re,frameProps:ae={},legendInteraction:le,legendPosition:ce,stroke:me,strokeWidth:de,opacity:fe,lineIdAccessor:we}=e,Se=y??!!x,Ce=te(N),Ae=ue(()=>k(n),[n]),xe=s({data:i??v,rawData:i,colorBy:O,colorScheme:G,legendInteraction:le,legendPosition:ce,selection:Y,linkedHover:Q,fallbackFields:O?["string"==typeof O?O:""]:[],unwrapData:!1,onObservation:V,onClick:ee,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"FlowMap",chartId:oe,showLegend:o.showLegend,userMargin:q,marginDefaults:{top:10,bottom:10,left:10,right:10},loading:ie,loadingContent:ne,emptyContent:re,width:o.width,height:o.height}),je=xe.data,Re=R(Q),Ie=z({name:Re?.name||"hover",fields:Re?.fields||[]}),Pe=T(e=>e.pushObservation),Me=ue(()=>{const e=new Map;for(const t of Ae)e.set(t[l]+"",t);return e},[Ae,l]),He=pe(null),Le=pe(Me);Le.current=Me;const Ne=pe(m);Ne.current=m;const ze=pe(u);ze.current=u;const Te=he(e=>{if(!e||"object"!=typeof e||null==e.source||null==e.target)return null;const t=Le.current,o=t.get(e.source+""),i=t.get(e.target+"");if(!o||!i)return null;const n="function"==typeof Ne.current?Ne.current:e=>e[Ne.current],r="function"==typeof ze.current?ze.current:e=>e[ze.current];return{...e,coordinates:[{[ve]:n(o),[ke]:r(o)},{[ve]:n(i),[ke]:r(i)}]}},[]);c(t,{variant:"geo-lines",frameRef:He,overrides:{push:e=>{const t=Te(e);t&&He.current?.pushLine(t)},pushMany:e=>{const t=[];for(const o of e){const e=Te(o);e&&t.push(e)}t.length>0&&He.current?.pushManyLines(t)}}});const Be=ue(()=>{const e=new Map;for(const t of je)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},[je]),Ee=he(e=>{if(Q)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"point"===e.type){const e=Be.get(t[l]+"");e&&Ie.onHover(e)}else Ie.onHover(t)}else Ie.onHover(null);if(V||Pe){const t={timestamp:Date.now(),chartType:"FlowMap",chartId:oe};if(e){let o=e.data||e.datum||e;Array.isArray(o)&&(o=o[0]);const i={...t,type:"hover",datum:o||{},x:e.x??0,y:e.y??0};V&&V(i),Pe&&Pe(i)}else{const e={...t,type:"hover-end"};V&&V(e),Pe&&Pe(e)}}},[Q,Ie,l,Be,V,oe,Pe]),We=xe.customClickBehavior,Oe=ue(()=>{const e="function"==typeof m?m:e=>e[m],t="function"==typeof u?u:e=>e[u];return je.map(o=>{if(!o||"object"!=typeof o||null==o.source||null==o.target)return null;const i=Me.get(o.source+""),n=Me.get(o.target+"");return i&&n?{...o,coordinates:[{[ve]:e(i),[ke]:t(i)},{[ve]:e(n),[ke]:t(n)}]}:null}).filter(Boolean)},[je,Me,m,u]),Fe=ue(()=>{const e="function"==typeof m?m:e=>e[m];return t=>null!=t&&"object"==typeof t&&ve in t?t[ve]:e(t)},[m]),De=ue(()=>{const e="function"==typeof u?u:e=>e[u];return t=>null!=t&&"object"==typeof t&&ke in t?t[ke]:e(t)},[u]),Ue=ue(()=>{const e=je.filter(e=>e&&"object"==typeof e).map(e=>e[h]??0).filter(e=>isFinite(e));return 0===e.length?()=>D[0]:ge().domain(W(e)).range(D)},[je,h,D]),Ze=ue(()=>e=>({stroke:O?w(e,O,xe.colorScale):b,strokeWidth:Ue(e[h]??0),strokeLinecap:Z,opacity:F}),[O,xe.colorScale,Ue,h,F,Z]),Ge=ue(()=>{const e=a(Ze,{stroke:me,strokeWidth:de,opacity:fe});if(!xe.effectiveSelectionHook)return e;const t={...xe.resolvedSelection?.unselectedStyle||{},fillOpacity:0};return E(e,xe.effectiveSelectionHook,{...xe.resolvedSelection||{},unselectedStyle:t})},[Ze,xe.effectiveSelectionHook,xe.resolvedSelection,me,de,fe]),$e=ue(()=>a(()=>({fill:"#333",r:5,fillOpacity:.8}),{stroke:me,strokeWidth:de,opacity:fe}),[me,de,fe]),Je=ue(()=>e=>{if(e?.geometry||e?.properties||e?.data?.geometry){const t=e?.properties?.name||e?.properties?.NAME||e?.name||e?.NAME||e?.data?.properties?.name||e?.data?.properties?.NAME;if(t)return ye("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12},children:ye("div",{style:{fontWeight:600},children:t})})}if(null!=e?.source&&null!=e?.target){const t=e[h];return be("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12},children:[be("div",{style:{fontWeight:600},children:[e.source," → ",e.target]}),null!=t&&ye("div",{style:{opacity:.7},children:"number"==typeof t?t.toLocaleString():t})]})}const t=e?.name||e?.label||e?.[l];return null!=t?ye("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12},children:ye("div",{style:{fontWeight:600},children:t})}):null},[h,l]);if(xe.earlyReturn)return xe.earlyReturn;const _e={projection:p,...null!=i&&{lines:Oe},points:Ae,xAccessor:Fe,yAccessor:De,lineDataAccessor:"coordinates",...null!=we&&{lineIdAccessor:we},lineType:M,flowStyle:H,lineStyle:Ge,pointStyle:$e,...Ce&&{areas:Ce,areaStyle:B},...null!=f&&{graticule:f},...null!=g&&{fitPadding:g},...Se&&{zoomable:!0},...S&&{zoomExtent:S},...C&&{onZoom:C},...null!=A&&{dragRotate:A},...$&&{showParticles:$},...J&&{particleStyle:J},...x&&{tileURL:x},...j&&{tileAttribution:j},...P&&{tileCacheSize:P},size:[o.width,o.height],margin:xe.margin,enableHover:!0,tooltipContent:!1===_?()=>null:I(_)||Je,...xe.legendBehaviorProps,...d({linkedHover:Q,selection:Y,onObservation:V,onClick:ee,mobileInteraction:xe.mobileInteraction,customHoverBehavior:Ee,customClickBehavior:We,linkedHoverInClickPredicate:!1}),...K&&K.length>0&&{annotations:K},...void 0!==e.autoPlaceAnnotations&&{autoPlaceAnnotations:e.autoPlaceAnnotations},...o.title&&{title:o.title},...o.description&&{description:o.description},...o.summary&&{summary:o.summary},...void 0!==o.accessibleTable&&{accessibleTable:o.accessibleTable},...X&&{className:X},...null!=e.animate&&{animate:e.animate},...ae};return ye(U,{componentName:"FlowMap",width:o.width,height:o.height,children:ye(r,{ref:He,..._e})})});we.displayName="FlowMap";import{useMemo as Se,useRef as Ce,useState as Ae,useEffect as xe,useCallback as je,forwardRef as Re}from"react";import{jsx as Ie,jsxs as Pe}from"react/jsx-runtime";var Me=Re(function(e,t){const o=L(e.mode,{width:e.width,height:e.height,showLegend:e.showLegend,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{points:i,lines:n,xAccessor:l="lon",yAccessor:m="lat",nodeIdAccessor:p="id",center:f,costAccessor:g,strength:y=1,lineMode:v="straight",projection:S="mercator",graticule:C,fitPadding:A,zoomable:x,zoomExtent:j,onZoom:R,dragRotate:P,tileURL:M,tileAttribution:H,tileCacheSize:N,transition:z,colorBy:T,styleRules:B,colorScheme:W,pointRadius:O=5,tooltip:F,showRings:D=!0,ringStyle:Z,showNorth:G=!0,costLabel:J,annotations:_,margin:K,className:q,selection:X,linkedHover:Y,onObservation:Q,onClick:V,chartId:ee,loading:te,loadingContent:oe,emptyContent:ie,legendPosition:ne,frameProps:re={},stroke:ae,strokeWidth:le,opacity:se}=e,ce=x??!!M,me=Se(()=>k(i),[i]),de=s({data:me,rawData:i,colorBy:T,colorScheme:W,legendInteraction:void 0,legendPosition:ne,selection:X,linkedHover:Y,fallbackFields:T?["string"==typeof T?T:""]:[],unwrapData:!1,onObservation:Q,onClick:V,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"DistanceCartogram",chartId:ee,showLegend:o.showLegend,userMargin:K,marginDefaults:{top:10,bottom:10,left:10,right:10},loading:te,loadingContent:oe,emptyContent:ie,width:o.width,height:o.height}),ue=Se(()=>{const e=u(e=>({fill:T?w(e,T,de.colorScale):b,fillOpacity:.8,stroke:"#fff",strokeWidth:1,r:O}),B,h(T)),t=a(e,{stroke:ae,strokeWidth:le,opacity:se});return de.effectiveSelectionHook?E(t,de.effectiveSelectionHook,de.resolvedSelection):t},[T,de.colorScale,de.effectiveSelectionHook,de.resolvedSelection,O,ae,le,se,B]),he=Se(()=>({center:f,centerAccessor:p,costAccessor:g,strength:y,lineMode:v}),[f,p,g,y,v]),pe=Se(()=>{if(!n)return;const e="function"==typeof l?l:e=>e[l],t="function"==typeof m?m:e=>e[m],o=new Map;for(const e of me)o.set(e[p]+"",e);return n.map(i=>{if(i.coordinates)return i;const n=o.get(i.source+""),r=o.get(i.target+"");return n&&r?{...i,coordinates:[{[l]:e(n),[m]:t(n)},{[l]:e(r),[m]:t(r)}]}:null}).filter(Boolean)},[n,me,l,m,p]),fe=Se(()=>e=>{const t=("function"==typeof g?g:e=>e[g])(e);return Pe("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12},children:[Ie("div",{style:{fontWeight:600},children:e[p]||e.name||e.id||"Point"}),null!=t&&Pe("div",{style:{opacity:.7},children:["Cost: ","number"==typeof t?t.toFixed(1):t]})]})},[g,p]),ge=Ce(null);c(t,{variant:"geo-points",frameRef:ge});const[ye,be]=Ae(null),ve=je(()=>{const e=ge.current?.getCartogramLayout?.();e&&be(t=>t&&t.cx===e.cx&&t.cy===e.cy&&t.maxCost===e.maxCost&&t.availableRadius===e.availableRadius?t:e)},[]);xe(()=>{const e=requestAnimationFrame(ve);return()=>cancelAnimationFrame(e)},[ve,y,f,o.width,o.height,me]);const ke=Se(()=>{if(!D||!ye)return[];const{maxCost:e}=ye;if(0>=e)return[];if(Array.isArray(D))return D.filter(t=>t>0&&e>=t);const t="number"==typeof D?D:Math.min(5,Math.max(2,Math.ceil(e/5))),o=e/t,i=[];for(let e=1;t>=e;e++)i.push(Math.round(o*e*10)/10);return i},[D,ye]),we=Se(()=>{if(!ye)return re.foregroundGraphics||null;const{cx:e,cy:t,maxCost:o,availableRadius:i}=ye,n={stroke:"#999",strokeWidth:.8,strokeDasharray:"4,3",labelColor:"#777",labelSize:10,...Z},r=de.margin.left??10,a=de.margin.top??10;return Pe("g",{children:[ke.map(l=>{const s=l/o*i;return Pe("g",{children:[Ie("circle",{cx:e+r,cy:t+a,r:s,fill:"none",stroke:n.stroke,strokeWidth:n.strokeWidth,strokeDasharray:n.strokeDasharray,opacity:.5}),Pe("text",{x:e+r+s+3,y:t+a-2,fontSize:n.labelSize,fill:n.labelColor,fontFamily:"system-ui, sans-serif",children:[l,J?" "+J:""]})]},l)}),G&&Pe("g",{transform:`translate(${r+24}, ${a+24})`,children:[Ie("circle",{r:16,fill:"white",fillOpacity:.85,stroke:"#bbb",strokeWidth:.8}),Ie("path",{d:"M0,-11 L3,-3 L1,-4 L1,7 L-1,7 L-1,-4 L-3,-3 Z",fill:"#555",stroke:"none"}),Ie("text",{y:-12,textAnchor:"middle",fontSize:7,fontWeight:700,fill:"#555",fontFamily:"system-ui, sans-serif",children:"N"}),Ie("line",{x1:11,y1:0,x2:13,y2:0,stroke:"#bbb",strokeWidth:.8}),Ie("line",{x1:-11,y1:0,x2:-13,y2:0,stroke:"#bbb",strokeWidth:.8}),Ie("line",{x1:0,y1:11,x2:0,y2:13,stroke:"#bbb",strokeWidth:.8})]}),re.foregroundGraphics]})},[ye,ke,G,J,Z,de.margin,re.foregroundGraphics]);if(de.earlyReturn)return de.earlyReturn;$("DistanceCartogram",me,"xAccessor",l),$("DistanceCartogram",me,"yAccessor",m);const Re={projection:S,...null!=i&&{points:me},...pe&&{lines:pe,lineDataAccessor:"coordinates"},xAccessor:l,yAccessor:m,pointIdAccessor:p,pointStyle:ue,projectionTransform:he,...z&&{transition:{duration:z}},...null!=C&&{graticule:C},...null!=A&&{fitPadding:A},...ce&&{zoomable:!0},...j&&{zoomExtent:j},...R&&{onZoom:R},...null!=P&&{dragRotate:P},...M&&{tileURL:M},...H&&{tileAttribution:H},...N&&{tileCacheSize:N},size:[o.width,o.height],margin:de.margin,enableHover:!0,tooltipContent:!1===F?()=>null:I(F)||fe,...de.legendBehaviorProps,...d({linkedHover:Y,selection:X,onObservation:Q,onClick:V,mobileInteraction:de.mobileInteraction,customHoverBehavior:de.customHoverBehavior,customClickBehavior:de.customClickBehavior,linkedHoverInClickPredicate:!1}),..._&&_.length>0&&{annotations:_},...void 0!==e.autoPlaceAnnotations&&{autoPlaceAnnotations:e.autoPlaceAnnotations},...o.title&&{title:o.title},...o.description&&{description:o.description},...o.summary&&{summary:o.summary},...void 0!==o.accessibleTable&&{accessibleTable:o.accessibleTable},...q&&{className:q},...null!=e.animate&&{animate:e.animate},...re,foregroundGraphics:we};return Ie(U,{componentName:"DistanceCartogram",width:o.width,height:o.height,children:Ie(r,{ref:ge,...Re})})});function He(e,t,o){const{featureKey:i,dataKey:n}=o,r=new Map;for(const e of t)r.set(e[n]+"",e);return e.map(e=>{const t=(e=>{const t=i.split(".");let o=e;for(const e of t)o=null!==o&&"object"==typeof o?o[e]:void 0;return(o??"")+""})(e),o=r.get(t);return o?{...e,properties:{...e.properties,...o}}:e})}Me.displayName="DistanceCartogram";export{ne as ChoroplethMap,e as DEFAULT_HIT_RADIUS,Me as DistanceCartogram,we as FlowMap,n as GeoCustomChart,de as ProportionalSymbolMap,r as StreamGeoFrame,u as composeStyleRules,t as geoAreaHitTarget,o as geoHitTarget,O as glyphExtent,F as glyphPlacement,A as hatchFillId,x as hatchPatternDef,i as hitTargetPoint,j as isHatchFill,h as makeNodeRuleContext,p as makeRuleValueResolver,f as matchesThreshold,He as mergeData,ee as resolveReferenceGeography,P as resolveResponsiveRules,g as resolveStyleRules,M as resolveSvgFill,H as responsiveRuleMatches,y as ruleMatches};