semiotic 3.8.8 → 3.8.9

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 (104) hide show
  1. package/CLAUDE.md +5 -4
  2. package/README.md +44 -44
  3. package/ai/schema.json +263 -1
  4. package/ai/surface-manifest.json +1 -1
  5. package/ai/system-prompt.md +1 -1
  6. package/dist/chunk-chunk-2X3FJCME.module.min.js +1 -0
  7. package/dist/{chunk-chunk-UEZ6SHW5.module.min.js → chunk-chunk-2ZHHWZQM.module.min.js} +1 -1
  8. package/dist/chunk-chunk-5ZON5NMV.module.min.js +2 -0
  9. package/dist/{chunk-chunk-L6FFYGYS.module.min.js → chunk-chunk-6S3YGYW7.module.min.js} +1 -1
  10. package/dist/chunk-chunk-7C5EDZ3Z.module.min.js +2 -0
  11. package/dist/chunk-chunk-A3I4HBD5.module.min.js +1 -0
  12. package/dist/{chunk-chunk-4MLLQUGW.module.min.js → chunk-chunk-AFQHURLO.module.min.js} +1 -1
  13. package/dist/{chunk-chunk-OG3TTJGJ.module.min.js → chunk-chunk-DDB4TLQG.module.min.js} +1 -1
  14. package/dist/{chunk-chunk-W5HWGQMD.module.min.js → chunk-chunk-DTH3SUOU.module.min.js} +1 -1
  15. package/dist/{chunk-chunk-H5IFO6CU.module.min.js → chunk-chunk-DVCWU7MT.module.min.js} +1 -1
  16. package/dist/{chunk-chunk-JRHXQGEV.module.min.js → chunk-chunk-FSIHAW6L.module.min.js} +1 -1
  17. package/dist/{chunk-chunk-BWV55BZK.module.min.js → chunk-chunk-G2RGVEYY.module.min.js} +1 -1
  18. package/dist/chunk-chunk-HAJVODLO.module.min.js +2 -0
  19. package/dist/{chunk-chunk-BZNOAHJV.module.min.js → chunk-chunk-HIV7AW2V.module.min.js} +1 -1
  20. package/dist/{chunk-chunk-LJDH3WV3.module.min.js → chunk-chunk-JZAMMSQQ.module.min.js} +1 -1
  21. package/dist/{chunk-chunk-VUWYT7DY.module.min.js → chunk-chunk-MXMRXSCI.module.min.js} +1 -1
  22. package/dist/chunk-chunk-MXVBXFKW.module.min.js +2 -0
  23. package/dist/{chunk-chunk-7LE56WAE.module.min.js → chunk-chunk-OFAP623Y.module.min.js} +1 -1
  24. package/dist/{chunk-chunk-SFLUSZ73.module.min.js → chunk-chunk-OHLRAEQZ.module.min.js} +1 -1
  25. package/dist/{chunk-chunk-CD6PVVS3.module.min.js → chunk-chunk-PRNXOCYZ.module.min.js} +1 -1
  26. package/dist/chunk-chunk-RLKZVJMQ.module.min.js +2 -0
  27. package/dist/chunk-chunk-SK2TQMG4.module.min.js +2 -0
  28. package/dist/chunk-chunk-SKLYXNYW.module.min.js +2 -0
  29. package/dist/{chunk-chunk-57RBPDBQ.module.min.js → chunk-chunk-U4NZCU5T.module.min.js} +1 -1
  30. package/dist/{chunk-chunk-QQJNG23C.module.min.js → chunk-chunk-VKL6DI43.module.min.js} +1 -1
  31. package/dist/chunk-chunk-W62673ZE.module.min.js +1 -0
  32. package/dist/{chunk-chunk-WSDJFBKX.module.min.js → chunk-chunk-XCC25CZZ.module.min.js} +1 -1
  33. package/dist/{chunk-chunk-AF53TBSN.module.min.js → chunk-chunk-XECNOUZY.module.min.js} +1 -1
  34. package/dist/{chunk-chunk-FC3NZWYR.module.min.js → chunk-chunk-XYZDTYAF.module.min.js} +1 -1
  35. package/dist/components/Tooltip/Tooltip.d.ts +54 -1
  36. package/dist/components/charts/physics/chainReactionTypes.d.ts +1 -0
  37. package/dist/components/charts/physics/physicsHocUtils.d.ts +1 -1
  38. package/dist/components/charts/realtime/RealtimeHeatmap.d.ts +2 -0
  39. package/dist/components/charts/realtime/RealtimeHistogram.d.ts +2 -0
  40. package/dist/components/charts/realtime/RealtimeLineChart.d.ts +2 -0
  41. package/dist/components/charts/realtime/RealtimeSwarmChart.d.ts +2 -0
  42. package/dist/components/charts/realtime/RealtimeWaterfallChart.d.ts +2 -0
  43. package/dist/components/charts/shared/formatUtils.d.ts +40 -9
  44. package/dist/components/charts/shared/streamPropsHelpers.d.ts +1 -0
  45. package/dist/components/charts/shared/types.d.ts +8 -1
  46. package/dist/components/semiotic-utils-core.d.ts +1 -0
  47. package/dist/components/semiotic.d.ts +4 -3
  48. package/dist/components/stream/GeoTileRenderer.d.ts +1 -0
  49. package/dist/components/stream/canvasSetup.d.ts +15 -4
  50. package/dist/components/stream/geoTypes.d.ts +2 -0
  51. package/dist/components/stream/networkFramePaint.d.ts +8 -0
  52. package/dist/components/stream/networkTypes.d.ts +2 -0
  53. package/dist/components/stream/ordinalTypes.d.ts +2 -0
  54. package/dist/components/stream/physics/StreamPhysicsTypes.d.ts +2 -0
  55. package/dist/components/stream/pipelineConfig.d.ts +2 -0
  56. package/dist/components/stream/pipelineDomainResolution.d.ts +1 -1
  57. package/dist/components/stream/types.d.ts +8 -1
  58. package/dist/components/stream/useCanvasFrameHost.d.ts +9 -0
  59. package/dist/components/stream/xyFrameAxisTypes.d.ts +5 -0
  60. package/dist/geo.min.js +1 -1
  61. package/dist/geo.module.min.js +1 -1
  62. package/dist/network.min.js +1 -1
  63. package/dist/network.module.min.js +1 -1
  64. package/dist/ordinal.min.js +1 -1
  65. package/dist/ordinal.module.min.js +1 -1
  66. package/dist/physics.min.js +1 -1
  67. package/dist/physics.module.min.js +1 -1
  68. package/dist/realtime.min.js +1 -1
  69. package/dist/realtime.module.min.js +1 -1
  70. package/dist/semiotic-ai-core.min.js +1 -1
  71. package/dist/semiotic-ai-core.module.min.js +1 -1
  72. package/dist/semiotic-ai.min.js +1 -1
  73. package/dist/semiotic-ai.module.min.js +1 -1
  74. package/dist/semiotic-experimental.min.js +1 -1
  75. package/dist/semiotic-experimental.module.min.js +1 -1
  76. package/dist/semiotic-realtime-core.min.js +1 -1
  77. package/dist/semiotic-realtime-core.module.min.js +1 -1
  78. package/dist/semiotic-server-edge.min.js +1 -1
  79. package/dist/semiotic-server-edge.module.min.js +1 -1
  80. package/dist/semiotic-server-node.min.js +1 -1
  81. package/dist/semiotic-server-node.module.min.js +1 -1
  82. package/dist/semiotic-utils-core.d.ts +1 -0
  83. package/dist/semiotic-utils-core.min.js +1 -1
  84. package/dist/semiotic-utils-core.module.min.js +1 -1
  85. package/dist/semiotic-utils.min.js +1 -1
  86. package/dist/semiotic-utils.module.min.js +1 -1
  87. package/dist/semiotic.d.ts +4 -3
  88. package/dist/semiotic.min.js +1 -1
  89. package/dist/semiotic.module.min.js +1 -1
  90. package/dist/server.min.js +1 -1
  91. package/dist/server.module.min.js +1 -1
  92. package/dist/xy.min.js +1 -1
  93. package/dist/xy.module.min.js +1 -1
  94. package/package.json +1 -1
  95. package/dist/chunk-chunk-3GCILWPB.module.min.js +0 -2
  96. package/dist/chunk-chunk-46KRGJQP.module.min.js +0 -1
  97. package/dist/chunk-chunk-7T25U75Z.module.min.js +0 -2
  98. package/dist/chunk-chunk-BTZYH2IE.module.min.js +0 -1
  99. package/dist/chunk-chunk-FRGBMTZR.module.min.js +0 -1
  100. package/dist/chunk-chunk-HCNDE26Q.module.min.js +0 -2
  101. package/dist/chunk-chunk-JJ4BSUYL.module.min.js +0 -2
  102. package/dist/chunk-chunk-N3Q33XCB.module.min.js +0 -2
  103. package/dist/chunk-chunk-RGJ6TKAH.module.min.js +0 -2
  104. package/dist/chunk-chunk-WGROBM3I.module.min.js +0 -2
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{DEFAULT_HIT_RADIUS as e,geoAreaHitTarget as t,geoHitTarget as o,hitTargetPoint as n}from"./chunk-chunk-J3XWETBJ.module.min.js";import{GeoCustomChart as i,StreamGeoFrame_default as r}from"./chunk-chunk-BWV55BZK.module.min.js";import{mergeShapeStyle as a,normalizePartialMargin as l,useChartSetup as s,useFrameImperativeHandle as c,useResolvedSelection as u}from"./chunk-chunk-VUWYT7DY.module.min.js";import"./chunk-chunk-AF53TBSN.module.min.js";import"./chunk-chunk-QQJNG23C.module.min.js";import"./chunk-chunk-W5HWGQMD.module.min.js";import{buildCustomBehaviorProps as d}from"./chunk-chunk-H5IFO6CU.module.min.js";import{useCustomLayoutSelection as m}from"./chunk-chunk-5UKL5W76.module.min.js";import"./chunk-chunk-FC3NZWYR.module.min.js";import{composeStyleRules as h,makeNodeRuleContext as p,makeRuleValueResolver as f,matchesThreshold as y,resolveStyleRules as g,ruleMatches as b}from"./chunk-chunk-EMO5NUGE.module.min.js";import"./chunk-chunk-SFLUSZ73.module.min.js";import"./chunk-chunk-4MLLQUGW.module.min.js";import{DEFAULT_COLOR as v,EMPTY_ARRAY as k,filterSparseArray as x,getColor as w,getSequentialInterpolator as S,getSize as M,hatchFillId as A,hatchPatternDef as C,isHatchFill as N,normalizeLinkedHover as R,normalizeTooltip as F,resolveAxisFreeMarginDefaults as j,resolveResponsiveRules as H,resolveSvgFill as I,responsiveRuleMatches as P,useChartMode as z,useChartSelection as L,useLinkedHover as W,useObservationSelector as O,useThemeSequential as B,wrapStyleWithSelection as T}from"./chunk-chunk-HCNDE26Q.module.min.js";import{getMinMax as D}from"./chunk-chunk-2NVFEB7P.module.min.js";import"./chunk-chunk-PMR47KRY.module.min.js";import{glyphExtent as E,glyphPlacement as $}from"./chunk-chunk-KTWEBFMX.module.min.js";import{ChartError as U,SafeRender as Z,renderEmptyState as G,renderLoadingState as q,warnMissingField as _}from"./chunk-chunk-ACLDBMRH.module.min.js";import"./chunk-chunk-YHNZCPOZ.module.min.js";import{useMemo as K}from"react";import{scaleSequential as J}from"d3-scale";import{useState as Q,useEffect as Y,useMemo as V}from"react";import{feature as X}from"topojson-client";var ee=new Map;function te(e){return"default"in e?e.default:e}async function oe(e){const t=ee.get(e);if(t)return t;const{topology:o,objectName:n}=await async function(e){try{switch(e){case"world-110m":return{topology:te(await import("world-atlas/countries-110m.json")),objectName:"countries"};case"world-50m":return{topology:te(await import("world-atlas/countries-50m.json")),objectName:"countries"};case"land-110m":return{topology:te(await import("world-atlas/land-110m.json")),objectName:"land"};case"land-50m":return{topology:te(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 i=X(o,o.objects[n]),r="features"in i?i.features:[i];return ee.set(e,r),r}function ne(e){const t=V(()=>Array.isArray(e)?e:void 0,[e]),[o,n]=Q(null);return Y(()=>{if(e&&!Array.isArray(e)){if("string"==typeof(t=e)&&["world-110m","world-50m","land-110m","land-50m"].includes(t)){let t=!1;return n(null),oe(e).then(e=>{t||n(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".`),n(null)}else n(null)},[e]),void 0!==t?t:o}import{jsx as ie,jsxs as re}from"react/jsx-runtime";function ae(e){const t=z(e.mode,{width:e.width,height:e.height,showLegend:e.showLegend,enableHover:e.enableHover,linkedHover:e.linkedHover,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),o=B(),{areas:n,valueAccessor:i,styleRules:s,colorScheme:c,projection:m="equalEarth",graticule:p,fitPadding:f,zoomable:y,zoomExtent:g,onZoom:b,dragRotate:v,tileURL:k,tileAttribution:w,tileCacheSize:M,tooltip:A,areaOpacity:C=1,annotations:N,margin:R,className:H,selection:I,linkedHover:P,onObservation:W,onClick:O,chartId:D,loading:E,loadingContent:$,emptyContent:_,frameProps:Q={},stroke:Y,strokeWidth:V,opacity:X}=e,ee=y??!!k,te=ne(n),oe=K(()=>te?x(te):te,[te]),ae=K(()=>"function"==typeof i?i:e=>e?.properties?.[i]??e?.[i],[i]),le=c??o??"blues",se=K(()=>{if(!oe)return J(S(void 0)).domain([0,1]);let e=1/0,t=-1/0;for(const o of oe){const n=ae(o);null!=n&&isFinite(n)&&(e>n&&(e=n),n>t&&(t=n))}const o=S(le);return J(o).domain([Number.isFinite(e)?e:0,Number.isFinite(t)?t:1])},[oe,ae,le]),{activeSelectionHook:ce,customHoverBehavior:ue,customClickBehavior:de}=L({selection:I,linkedHover:P,onObservation:W,onClick:O,chartType:"ChoroplethMap",chartId:D,mobileInteraction:t.mobileInteraction}),me=u(I),he=K(()=>{const e=h(e=>{const t=ae(e);return{fill:null!=t&&isFinite(t)?se(t):"#ccc",stroke:"#999",strokeWidth:.5,fillOpacity:C}},s,e=>({value:ae(e)}),e=>e&&"object"==typeof e&&e.properties?{...e.properties,...e}:e),t=a(e,{stroke:Y,strokeWidth:V,opacity:X});return ce?T(t,ce,me):t},[ae,se,ce,me,C,Y,V,X,s]),pe=K(()=>e=>{const t=e?.properties?.name||e?.properties?.NAME||e?.name||e?.NAME||"Feature",o=ae(e);return re("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:t}),null!=o&&ie("div",{style:{opacity:.7},children:(n=o,"number"==typeof n&&isFinite(n)?Number.isInteger(n)?n.toLocaleString():n.toLocaleString(void 0,{maximumFractionDigits:2}):(n??"")+"")})]});var n},[ae]),fe=j(t),ye=K(()=>({...fe,...l(R)}),[fe,R]),ge=q(E,t.width,t.height,$)||(oe?null:q(!0,t.width,t.height,$)),be=ge?null:G(oe,t.width,t.height,_);if(Array.isArray(oe)&&oe.length>0){const e=oe[0];if(!e||"object"!=typeof e||!e.geometry)return ie(U,{componentName:"ChoroplethMap",message:"ChoroplethMap: areas must be an array of GeoJSON Features with a geometry property.",width:t.width,height:t.height})}const ve={projection:m,areas:oe,areaStyle:he,size:[t.width,t.height],margin:ye,enableHover:t.enableHover,tooltipContent:!1===A?()=>null:!0===A?pe:F(A)||pe,...null!=p&&{graticule:p},...null!=f&&{fitPadding:f},...ee&&{zoomable:!0},...g&&{zoomExtent:g},...b&&{onZoom:b},...null!=v&&{dragRotate:v},...k&&{tileURL:k},...w&&{tileAttribution:w},...M&&{tileCacheSize:M},...d({linkedHover:P,selection:I,onObservation:W,onClick:O,mobileInteraction:t.mobileInteraction,customHoverBehavior:ue,customClickBehavior:de,linkedHoverInClickPredicate:!1}),...N&&N.length>0&&{annotations:N},...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},...H&&{className:H},...null!=e.animate&&{animate:e.animate},...Q};return ge||be||ie(Z,{componentName:"ChoroplethMap",width:t.width,height:t.height,children:ie(r,{...ve})})}ae.displayName="ChoroplethMap";import{useMemo as le,useRef as se,forwardRef as ce}from"react";var ue={fill:"#f0f0f0",stroke:"#ccc",strokeWidth:.5};import{jsx as de,jsxs as me}from"react/jsx-runtime";var he=[3,30],pe=[1,4],fe=ce(function(e,t){const o=se(null);c(t,{variant:"geo-points",frameRef:o});const n=z(e.mode,{width:e.width,height:e.height,showLegend:e.showLegend,enableHover:e.enableHover,linkedHover:e.linkedHover,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{points:i,xAccessor:l="lon",yAccessor:u="lat",sizeBy:m,sizeRange:f,colorBy:y,styleRules:g,colorScheme:b,projection:x="equalEarth",graticule:S,fitPadding:A,zoomable:C,zoomExtent:N,onZoom:R,dragRotate:H,tileURL:I,tileAttribution:P,tileCacheSize:L,areas:W,areaStyle:O=ue,tooltip:B,annotations:E,margin:$,className:U,selection:G,linkedHover:q,onObservation:K,onClick:J,chartId:Q,loading:Y,loadingContent:V,emptyContent:X,legendInteraction:ee,legendPosition:te,frameProps:oe={},stroke:ie,strokeWidth:re,opacity:ae}=e,ce=f??("sparkline"===n.mode?pe:he),fe="sparkline"===n.mode?1.5:6,ye=C??!!I,ge=ne(W),be=s({data:i??k,rawData:i,colorBy:y,colorScheme:b,legendInteraction:ee,legendPosition:te,selection:G,linkedHover:q,fallbackFields:y?["string"==typeof y?y:""]:[],unwrapData:!1,onObservation:K,onClick:J,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"ProportionalSymbolMap",chartId:Q,showLegend:n.showLegend,userMargin:$,marginDefaults:j(n),loading:Y,loadingContent:V,emptyContent:X,width:n.width,height:n.height,hasTitle:!!n.title}),ve=be.data,ke=le(()=>{if(!m)return;const e="function"==typeof m?m:e=>e?.[m],t=ve.filter(Boolean).map(t=>e(t)).filter(e=>null!=e&&isFinite(e));return 0!==t.length?D(t):void 0},[ve,m]),xe=le(()=>{const e=h(e=>({fill:y?w(e,y,be.colorScale):v,fillOpacity:.7,stroke:"#fff",strokeWidth:.5,r:m?M(e,m,ce,ke):fe}),g,p(y,m)),t=a(e,{stroke:ie,strokeWidth:re,opacity:ae});return be.effectiveSelectionHook?T(t,be.effectiveSelectionHook,be.resolvedSelection):t},[y,be.colorScale,be.effectiveSelectionHook,be.resolvedSelection,m,ce,ke,fe,ie,re,ae,g]),we=le(()=>e=>{const t=e?.name||e?.label||e?.NAME||e?.id,o="string"==typeof m?m:null,n=("function"==typeof m?m:e=>e[m])(e),i=e=>"number"==typeof e&&isFinite(e)?Number.isInteger(e)?e.toLocaleString():e.toLocaleString(void 0,{maximumFractionDigits:2}):(e??"")+"",r="string"==typeof y?y: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&&de("div",{style:{fontWeight:600,marginBottom:2},children:t}),o&&null!=n&&me("div",{children:[me("span",{style:{opacity:.7},children:[o,": "]}),i(n)]}),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,": "]}),i(t)]},e))]})},[m,y]);if(be.earlyReturn)return be.earlyReturn;_("ProportionalSymbolMap",ve,"xAccessor",l),_("ProportionalSymbolMap",ve,"yAccessor",u);const Se={projection:x,...null!=i&&{points:ve},xAccessor:l,yAccessor:u,pointStyle:xe,...e.pointIdAccessor&&{pointIdAccessor:e.pointIdAccessor},...ge&&{areas:ge,areaStyle:O},...null!=S&&{graticule:S},...null!=A&&{fitPadding:A},...ye&&{zoomable:!0},...N&&{zoomExtent:N},...R&&{onZoom:R},...null!=H&&{dragRotate:H},...I&&{tileURL:I},...P&&{tileAttribution:P},...L&&{tileCacheSize:L},size:[n.width,n.height],margin:be.margin,enableHover:n.enableHover,tooltipContent:!1===B?()=>null:F(B)||we,...be.legendBehaviorProps,...d({linkedHover:q,selection:G,onObservation:K,onClick:J,mobileInteraction:be.mobileInteraction,customHoverBehavior:be.customHoverBehavior,customClickBehavior:be.customClickBehavior,linkedHoverInClickPredicate:!1}),...E&&E.length>0&&{annotations:E},...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},...U&&{className:U},...null!=e.animate&&{animate:e.animate},...oe};return de(Z,{componentName:"ProportionalSymbolMap",width:n.width,height:n.height,children:de(r,{ref:o,...Se})})});fe.displayName="ProportionalSymbolMap";import{useMemo as ye,useCallback as ge,useRef as be,forwardRef as ve}from"react";import{scaleLinear as ke}from"d3-scale";import{jsx as xe,jsxs as we}from"react/jsx-runtime";var Se="__semiotic_x",Me="__semiotic_y",Ae=ve(function(e,t){const o=z(e.mode,{width:e.width,height:e.height,showLegend:e.showLegend,enableHover:e.enableHover,linkedHover:e.linkedHover,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{flows:n,nodes:i,nodeIdAccessor:l="id",xAccessor:u="lon",yAccessor:m="lat",valueAccessor:h="value",projection:p="equalEarth",graticule:f,fitPadding:y,zoomable:g,zoomExtent:b,onZoom:S,dragRotate:M,tileURL:A,tileAttribution:C,tileCacheSize:N,lineType:H="geo",flowStyle:I="basic",areas:P,areaStyle:L=ue,edgeColorBy:B,edgeOpacity:E=.6,edgeWidthRange:$=[1,8],pointRadius:U,edgeLinecap:G="round",colorScheme:q,showParticles:_,particleStyle:K,tooltip:J,annotations:Q,margin:Y,className:V,selection:X,linkedHover:ee,onObservation:te,onClick:oe,chartId:ie,loading:re,loadingContent:ae,emptyContent:le,frameProps:se={},legendInteraction:ce,legendPosition:de,stroke:me,strokeWidth:he,opacity:pe,lineIdAccessor:fe}=e,ve=g??!!A,Ae=ne(P),Ce=ye(()=>x(i),[i]),Ne=s({data:n??k,rawData:n,colorBy:B,colorScheme:q,legendInteraction:ce,legendPosition:de,selection:X,linkedHover:ee,fallbackFields:B?["string"==typeof B?B:""]:[],unwrapData:!1,onObservation:te,onClick:oe,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"FlowMap",chartId:ie,showLegend:o.showLegend,userMargin:Y,marginDefaults:j(o),loading:re,loadingContent:ae,emptyContent:le,width:o.width,height:o.height,hasTitle:!!o.title}),Re=Ne.data,Fe=R(ee),je=W({name:Fe?.name||"hover",fields:Fe?.fields||[]}),He=O(e=>e.pushObservation),Ie=ye(()=>{const e=new Map;for(const t of Ce)e.set(t[l]+"",t);return e},[Ce,l]),Pe=be(null),ze=be(Ie);ze.current=Ie;const Le=be(u);Le.current=u;const We=be(m);We.current=m;const Oe=ge(e=>{if(!e||"object"!=typeof e||null==e.source||null==e.target)return null;const t=ze.current,o=t.get(e.source+""),n=t.get(e.target+"");if(!o||!n)return null;const i="function"==typeof Le.current?Le.current:e=>e[Le.current],r="function"==typeof We.current?We.current:e=>e[We.current];return{...e,coordinates:[{[Se]:i(o),[Me]:r(o)},{[Se]:i(n),[Me]:r(n)}]}},[]);c(t,{variant:"geo-lines",frameRef:Pe,overrides:{push:e=>{const t=Oe(e);t&&Pe.current?.pushLine(t)},pushMany:e=>{const t=[];for(const o of e){const e=Oe(o);e&&t.push(e)}t.length>0&&Pe.current?.pushManyLines(t)}}});const Be=ye(()=>{const e=new Map;for(const t of Re)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},[Re]),Te=ge(e=>{if(ee)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&&je.onHover(e)}else je.onHover(t)}else je.onHover(null);if(te||He){const t={timestamp:Date.now(),chartType:"FlowMap",chartId:ie};if(e){let o=e.data||e.datum||e;Array.isArray(o)&&(o=o[0]);const n={...t,type:"hover",datum:o||{},x:e.x??0,y:e.y??0};te&&te(n),He&&He(n)}else{const e={...t,type:"hover-end"};te&&te(e),He&&He(e)}}},[ee,je,l,Be,te,ie,He]),De=Ne.customClickBehavior,Ee=ye(()=>{const e="function"==typeof u?u:e=>e[u],t="function"==typeof m?m:e=>e[m];return Re.map(o=>{if(!o||"object"!=typeof o||null==o.source||null==o.target)return null;const n=Ie.get(o.source+""),i=Ie.get(o.target+"");return n&&i?{...o,coordinates:[{[Se]:e(n),[Me]:t(n)},{[Se]:e(i),[Me]:t(i)}]}:null}).filter(Boolean)},[Re,Ie,u,m]),$e=ye(()=>{const e="function"==typeof u?u:e=>e[u];return t=>null!=t&&"object"==typeof t&&Se in t?t[Se]:e(t)},[u]),Ue=ye(()=>{const e="function"==typeof m?m:e=>e[m];return t=>null!=t&&"object"==typeof t&&Me in t?t[Me]:e(t)},[m]),Ze=ye(()=>{const e=Re.filter(e=>e&&"object"==typeof e).map(e=>e[h]??0).filter(e=>isFinite(e));return 0===e.length?()=>$[0]:ke().domain(D(e)).range($)},[Re,h,$]),Ge=ye(()=>e=>({stroke:B?w(e,B,Ne.colorScale):v,strokeWidth:Ze(e[h]??0),strokeLinecap:G,opacity:E}),[B,Ne.colorScale,Ze,h,E,G]),qe=ye(()=>{const e=a(Ge,{stroke:me,strokeWidth:he,opacity:pe});if(!Ne.effectiveSelectionHook)return e;const t={...Ne.resolvedSelection?.unselectedStyle||{},fillOpacity:0};return T(e,Ne.effectiveSelectionHook,{...Ne.resolvedSelection||{},unselectedStyle:t})},[Ge,Ne.effectiveSelectionHook,Ne.resolvedSelection,me,he,pe]),_e=U??("sparkline"===o.mode?1.5:5),Ke=ye(()=>a(()=>({fill:"#333",r:_e,fillOpacity:.8}),{stroke:me,strokeWidth:he,opacity:pe}),[_e,me,he,pe]),Je=ye(()=>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 xe("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12},children:xe("div",{style:{fontWeight:600},children:t})})}if(null!=e?.source&&null!=e?.target){const t=e[h];return we("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12},children:[we("div",{style:{fontWeight:600},children:[e.source," → ",e.target]}),null!=t&&xe("div",{style:{opacity:.7},children:"number"==typeof t?t.toLocaleString():t})]})}const t=e?.name||e?.label||e?.[l];return null!=t?xe("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12},children:xe("div",{style:{fontWeight:600},children:t})}):null},[h,l]);if(Ne.earlyReturn)return Ne.earlyReturn;const Qe={projection:p,...null!=n&&{lines:Ee},points:Ce,xAccessor:$e,yAccessor:Ue,lineDataAccessor:"coordinates",...null!=fe&&{lineIdAccessor:fe},lineType:H,flowStyle:I,lineStyle:qe,pointStyle:Ke,...Ae&&{areas:Ae,areaStyle:L},...null!=f&&{graticule:f},...null!=y&&{fitPadding:y},...ve&&{zoomable:!0},...b&&{zoomExtent:b},...S&&{onZoom:S},...null!=M&&{dragRotate:M},..._&&{showParticles:_},...K&&{particleStyle:K},...A&&{tileURL:A},...C&&{tileAttribution:C},...N&&{tileCacheSize:N},size:[o.width,o.height],margin:Ne.margin,enableHover:o.enableHover,tooltipContent:!1===J?()=>null:F(J)||Je,...Ne.legendBehaviorProps,...d({linkedHover:ee,selection:X,onObservation:te,onClick:oe,mobileInteraction:Ne.mobileInteraction,customHoverBehavior:Te,customClickBehavior:De,linkedHoverInClickPredicate:!1}),...Q&&Q.length>0&&{annotations:Q},...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},...V&&{className:V},...null!=e.animate&&{animate:e.animate},...se};return xe(Z,{componentName:"FlowMap",width:o.width,height:o.height,children:xe(r,{ref:Pe,...Qe})})});Ae.displayName="FlowMap";import{useMemo as Ce,useRef as Ne,useState as Re,useEffect as Fe,useCallback as je,forwardRef as He}from"react";import{Fragment as Ie,jsx as Pe,jsxs as ze}from"react/jsx-runtime";var Le=He(function(e,t){const o=z(e.mode,{width:e.width,height:e.height,showLegend:e.showLegend,enableHover:e.enableHover,linkedHover:e.linkedHover,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{points:n,lines:i,xAccessor:l="lon",yAccessor:u="lat",nodeIdAccessor:m="id",center:f,costAccessor:y,strength:g=1,lineMode:b="straight",projection:k="mercator",graticule:S,fitPadding:M,zoomable:A,zoomExtent:C,onZoom:N,dragRotate:R,tileURL:H,tileAttribution:I,tileCacheSize:P,transition:L,colorBy:W,styleRules:O,colorScheme:B,pointRadius:D,tooltip:E,showRings:$,showRingLabels:U,ringStyle:G,showNorth:q,costLabel:K,cartogramLayout:J,annotations:Q,margin:Y,className:V,selection:X,linkedHover:ee,onObservation:te,onClick:oe,chartId:ne,loading:ie,loadingContent:re,emptyContent:ae,legendPosition:le,frameProps:se={},stroke:ce,strokeWidth:ue,opacity:de}=e,me="sparkline"===o.mode,he=J??(me?"strip":"radial"),pe=D??(me?1.5:5),fe=$??!0,ye=U??("strip"!==he&&!o.compactMode),ge=q??("strip"!==he&&!me),be=A??!!H,ve=Ce(()=>x(n),[n]),ke=s({data:ve,rawData:n,colorBy:W,colorScheme:B,legendInteraction:void 0,legendPosition:le,selection:X,linkedHover:ee,fallbackFields:W?["string"==typeof W?W:""]:[],unwrapData:!1,onObservation:te,onClick:oe,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"DistanceCartogram",chartId:ne,showLegend:o.showLegend,userMargin:Y,marginDefaults:j(o),loading:ie,loadingContent:re,emptyContent:ae,width:o.width,height:o.height,hasTitle:!!o.title}),xe=Ce(()=>{const e=h(e=>{const t=e?.[m],o=null!=t&&t+""==f+"";return{fill:W?w(e,W,ke.colorScale):v,fillOpacity:o?1:.8,stroke:o?"var(--semiotic-text, #222)":"#fff",strokeWidth:o?1.25:1,r:o?1.35*pe:pe}},O,p(W)),t=a(e,{stroke:ce,strokeWidth:ue,opacity:de});return ke.effectiveSelectionHook?T(t,ke.effectiveSelectionHook,ke.resolvedSelection):t},[W,ke.colorScale,ke.effectiveSelectionHook,ke.resolvedSelection,pe,ce,ue,de,O,f,m]),we=Ce(()=>({center:f,centerAccessor:m,costAccessor:y,strength:g,lineMode:b,layout:he}),[f,m,y,g,b,he]),Se=Ce(()=>{if(!i)return;const e="function"==typeof l?l:e=>e[l],t="function"==typeof u?u:e=>e[u],o=new Map;for(const e of ve)o.set(e[m]+"",e);return i.map(n=>{if(n.coordinates)return n;const i=o.get(n.source+""),r=o.get(n.target+"");return i&&r?{...n,coordinates:[{[l]:e(i),[u]:t(i)},{[l]:e(r),[u]:t(r)}]}:null}).filter(Boolean)},[i,ve,l,u,m]),Me=Ce(()=>e=>{const t=("function"==typeof y?y:e=>e[y])(e);return ze("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12},children:[Pe("div",{style:{fontWeight:600},children:e[m]||e.name||e.id||"Point"}),null!=t&&ze("div",{style:{opacity:.7},children:["Cost: ","number"==typeof t?t.toFixed(1):t]})]})},[y,m]),Ae=Ne(null);c(t,{variant:"geo-points",frameRef:Ae});const[He,Le]=Re(null),We=je(()=>{const e=Ae.current?.getCartogramLayout?.();e&&Le(t=>t&&t.cx===e.cx&&t.cy===e.cy&&t.maxCost===e.maxCost&&t.availableRadius===e.availableRadius&&t.layout===(e.layout??"radial")?t:{cx:e.cx,cy:e.cy,maxCost:e.maxCost,availableRadius:e.availableRadius,layout:e.layout??"radial"})},[]);Fe(()=>{const e=requestAnimationFrame(We);return()=>cancelAnimationFrame(e)},[We,g,f,o.width,o.height,ve,he]);const Oe=Ce(()=>{if(!fe||!He)return[];const{maxCost:e}=He;if(0>=e)return[];if(Array.isArray(fe))return fe.filter(t=>t>0&&e>=t);const t="number"==typeof fe?fe:Math.min("strip"===He.layout?3:5,Math.max(2,Math.ceil(e/5))),o=e/t,n=[];for(let e=1;t>=e;e++)n.push(Math.round(o*e*10)/10);return n},[fe,He]),Be=Ce(()=>{if(!He)return se.foregroundGraphics||null;const{cx:e,cy:t,maxCost:o,availableRadius:n,layout:i}=He,r="strip"===i,a={stroke:r?"var(--semiotic-border, #999)":"#999",strokeWidth:r?1:.8,strokeDasharray:r?"none":"4,3",labelColor:"var(--semiotic-text-secondary, #777)",labelSize:r?8:10,...G},l=ke.margin.left??10,s=ke.margin.top??10,c=e+l,u=t+s;return ze("g",{children:[ze(Ie,r?{children:[Pe("line",{x1:c,y1:u,x2:c+n,y2:u,stroke:a.stroke,strokeWidth:a.strokeWidth,strokeLinecap:"round",opacity:.85}),Pe("line",{x1:c,y1:u-3.5,x2:c,y2:u+3.5,stroke:a.stroke,strokeWidth:a.strokeWidth,opacity:.9}),fe&&Oe.map(e=>{const t=c+(o>0?e/o*n:0);return ze("g",{children:[Pe("line",{x1:t,y1:u-2.5,x2:t,y2:u+2.5,stroke:a.stroke,strokeWidth:.9,opacity:.65}),ye&&ze("text",{x:t,y:u+Math.min(10,(ke.margin.bottom??2)+8),textAnchor:"middle",fontSize:a.labelSize,fill:a.labelColor,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",children:[e,K?" "+K:""]})]},e)})]}:{children:[Oe.map(e=>{const t=e/o*n;return ze("g",{children:[Pe("circle",{cx:c,cy:u,r:t,fill:"none",stroke:a.stroke,strokeWidth:a.strokeWidth,strokeDasharray:a.strokeDasharray,opacity:.5}),ye&&ze("text",{x:c+t+3,y:u-2,fontSize:a.labelSize,fill:a.labelColor,fontFamily:"system-ui, sans-serif",children:[e,K?" "+K:""]})]},e)}),ge&&ze("g",{transform:`translate(${l+24}, ${s+24})`,children:[Pe("circle",{r:16,fill:"white",fillOpacity:.85,stroke:"#bbb",strokeWidth:.8}),Pe("path",{d:"M0,-11 L3,-3 L1,-4 L1,7 L-1,7 L-1,-4 L-3,-3 Z",fill:"#555",stroke:"none"}),Pe("text",{y:-12,textAnchor:"middle",fontSize:7,fontWeight:700,fill:"#555",fontFamily:"system-ui, sans-serif",children:"N"}),Pe("line",{x1:11,y1:0,x2:13,y2:0,stroke:"#bbb",strokeWidth:.8}),Pe("line",{x1:-11,y1:0,x2:-13,y2:0,stroke:"#bbb",strokeWidth:.8}),Pe("line",{x1:0,y1:11,x2:0,y2:13,stroke:"#bbb",strokeWidth:.8})]})]}),se.foregroundGraphics]})},[He,Oe,fe,ye,ge,K,G,ke.margin,se.foregroundGraphics]);if(ke.earlyReturn)return ke.earlyReturn;_("DistanceCartogram",ve,"xAccessor",l),_("DistanceCartogram",ve,"yAccessor",u);const Te={projection:k,...null!=n&&{points:ve},...Se&&{lines:Se,lineDataAccessor:"coordinates"},xAccessor:l,yAccessor:u,pointIdAccessor:m,pointStyle:xe,projectionTransform:we,...L&&{transition:{duration:L}},...null!=S&&{graticule:S},...null!=M&&{fitPadding:M},...be&&{zoomable:!0},...C&&{zoomExtent:C},...N&&{onZoom:N},...null!=R&&{dragRotate:R},...H&&{tileURL:H},...I&&{tileAttribution:I},...P&&{tileCacheSize:P},size:[o.width,o.height],margin:ke.margin,enableHover:o.enableHover,tooltipContent:!1===E?()=>null:F(E)||Me,...ke.legendBehaviorProps,...d({linkedHover:ee,selection:X,onObservation:te,onClick:oe,mobileInteraction:ke.mobileInteraction,customHoverBehavior:ke.customHoverBehavior,customClickBehavior:ke.customClickBehavior,linkedHoverInClickPredicate:!1}),...Q&&Q.length>0&&{annotations:Q},...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},...V&&{className:V},...null!=e.animate&&{animate:e.animate},...se,foregroundGraphics:Be};return Pe(Z,{componentName:"DistanceCartogram",width:o.width,height:o.height,children:Pe(r,{ref:Ae,...Te})})});Le.displayName="DistanceCartogram";import{jsx as We}from"react/jsx-runtime";function Oe(e){if(Number.isFinite(e))return Math.max(1,Math.round(e))}function Be(e,t,o){return Math.max(t,Math.min(o,e))}function Te(e){let t=1/0,o=-1/0;for(const n of e)Number.isFinite(n)&&(t>n&&(t=n),n>o&&(o=n));return t===1/0?[0,0]:[t,o]}function De(e,t){const o=t[1]-t[0];return 0===o?.5:(e-t[0])/o}function Ee(e,t={}){const o=e.map((e,t)=>({...e,index:t})).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y));if(0===o.length)return[];const n=Be(Number.isFinite(t.occupancy)?Number(t.occupancy):.72,.2,1),i=Number.isFinite(t.aspectRatio)&&Number(t.aspectRatio)>0?Number(t.aspectRatio):1.8;let r=Oe(t.columns)??Math.max(1,Math.ceil(Math.sqrt(o.length*i/n))),a=Oe(t.rows)??Math.max(1,Math.ceil(o.length/(r*n)));o.length>r*a&&(null!=t.columns&&null==t.rows?a=Math.ceil(o.length/r):null!=t.rows&&null==t.columns?r=Math.ceil(o.length/a):a=Math.ceil(o.length/r));const l=Te(o.map(e=>e.x)),s=Te(o.map(e=>e.y)),c=o.map(e=>({...e,desiredColumn:De(e.x,l)*Math.max(0,r-1),desiredRow:De(e.y,s)*Math.max(0,a-1)})),u=(r-1)/2,d=(a-1)/2;c.sort((e,t)=>(t.desiredColumn-u)**2+(t.desiredRow-d)**2-((e.desiredColumn-u)**2+(e.desiredRow-d)**2)||e.desiredRow-t.desiredRow||e.desiredColumn-t.desiredColumn||e.index-t.index);const m=new Set;for(let e=0;a>e;e+=1)for(let t=0;r>t;t+=1)m.add(e*r+t);const h=[];for(const e of c){let t=-1,o=1/0;for(const n of m){const i=(n%r-e.desiredColumn)**2+(Math.floor(n/r)-e.desiredRow)**2;(o>i||i===o&&t>n)&&(t=n,o=i)}0>t||(m.delete(t),h.push({datum:e.datum,x:e.x,y:e.y,row:Math.floor(t/r),column:t%r,index:e.index}))}return h.sort((e,t)=>e.index-t.index),h.map(({index:e,...t})=>t)}function $e(e,t,o=[]){if("function"==typeof t)return t(e);if("string"==typeof t)return e[t];for(const t of o)if(null!=e[t])return e[t]}function Ue(e){return e.map(([e,t],o)=>`${0===o?"M":"L"}${e},${t}`).join("")+"Z"}var Ze=e=>{const t=e.config,o=t.source??"auto",n="areas"===o||"auto"===o&&e.areas.length>0,i=n?function(e){return e.areas.map((t,o)=>{const n=function(e,t){const o=e.properties&&"object"==typeof e.properties?e.properties:{},n=e.id??o.id??o.name??"area-"+t;return{...o,id:n+""}}(t,o),i=e.scales.geoPath.centroid(t),r=Number.isFinite(i[0])&&Number.isFinite(i[1])?e.scales.invertedPoint(i[0],i[1]):null;return{datum:{...n,gridLongitude:r?.[0],gridLatitude:r?.[1]},x:i[0],y:i[1]}}).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y))}(e):e.points.map((e,t)=>({datum:e,x:t,y:t})),r=i.filter((e,o)=>!t.filter||t.filter(e.datum,o)),a=function(e,t){if(!t.rowAccessor||!t.columnAccessor)return null;const o=e.map(e=>({datum:e,x:Number($e(e,t.columnAccessor)),y:Number($e(e,t.rowAccessor))})).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y));return o.length!==e.length?null:o.map(e=>({...e,row:e.y,column:e.x}))}(r.map(e=>e.datum),t),l=n?r:function(e){return e.points.map(t=>{const o=Number($e(t,e.config.longitudeAccessor,["lon","longitude"])),n=Number($e(t,e.config.latitudeAccessor,["lat","latitude"])),i=Number.isFinite(o)&&Number.isFinite(n)?e.scales.projectedPoint(o,n):null;return{datum:t,x:i?.[0]??NaN,y:i?.[1]??NaN}}).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y))}({...e,points:r.map(e=>e.datum)}),s=a??Ee(l,{columns:t.columns,rows:t.rows,occupancy:t.occupancy,aspectRatio:e.dimensions.width/Math.max(1,e.dimensions.height)});if(0===s.length)return{nodes:[]};const c=Te(s.map(e=>e.row)),u=Te(s.map(e=>e.column)),d=Math.max(1,Math.round(c[1]-c[0])+1),m=Math.max(1,Math.round(u[1]-u[0])+1),h=Math.max(0,t.layoutPadding??8),p=Math.max(1,e.dimensions.width-2*h)/m,f=Math.max(1,e.dimensions.height-2*h)/d,y=(e.dimensions.width-p*m)/2,g=(e.dimensions.height-f*d)/2,b=Be(t.cellPadding??.12,0,.8),v=Math.max(1,.5*Math.min(p,f)*(1-b)),k=t.sizeAccessor?s.map(e=>Number($e(e.datum,t.sizeAccessor))):[],x=t.sizeDomain??Te(k),w=t.sizeRange??[.36,1],S=Be(Math.min(w[0],w[1]),.05,1),M=Be(Math.max(w[0],w[1]),S,1),A=s.map((o,n)=>{const i={...o.datum,gridRow:o.row,gridColumn:o.column},r=($e(i,t.idAccessor,["id","key","name"])??"grid-"+n)+"",a=($e(i,t.labelAccessor,["abbr","code","label","name","id"])??r)+"",l=Math.max(1,t.maxLabelLength??4),s=a.length>l?a.slice(0,l):a,d=$e(i,t.categoryAccessor),m=null==d?void 0:d+"",h=$e(i,t.fillAccessor),b=null!=h?h+"":m?e.resolveColor(m):e.theme.categorical[0]??"#4f86c6",k=t.sizeAccessor?Number($e(i,t.sizeAccessor)):NaN,w=t.sizeAccessor&&Number.isFinite(k)?Math.sqrt(Be(De(k,x),0,1)):1,A=v*(S+w*(M-S)),C="function"==typeof t.markStyle?t.markStyle(i,n):t.markStyle;return{datum:i,id:r,label:s,category:m,row:o.row,column:o.column,x:y+(o.column-u[0]+.5)*p,y:g+(o.row-c[0]+.5)*f,radius:A,style:{fill:b,fillOpacity:.94,stroke:"rgba(255,255,255,0.9)",strokeWidth:1,...C}}}),C=t.shape??"circle";return{nodes:A.map(e=>{return"circle"===C?{type:"point",x:e.x,y:e.y,r:e.radius,style:e.style,datum:e.datum,accessibleDatum:e.datum,accessibility:{label:e.label,tableFields:{name:e.datum.name??e.label,label:e.label,row:e.row,column:e.column,...e.category?{category:e.category}:{}}},pointId:e.id,_transitionKey:e.id}:{type:"geoarea",pathData:"hexagon"===C?function(e,t,o){const n=[];for(let i=0;6>i;i+=1){const r=-Math.PI/2+i*(Math.PI/3);n.push([e+Math.cos(r)*o,t+Math.sin(r)*o])}return Ue(n)}(e.x,e.y,e.radius):Ue([[(t=e.x)-(n=e.radius),(o=e.y)-n],[t+n,o-n],[t+n,o+n],[t-n,o+n]]),centroid:[e.x,e.y],bounds:[[e.x-e.radius,e.y-e.radius],[e.x+e.radius,e.y+e.radius]],screenArea:"hexagon"===C?3*Math.sqrt(3)*e.radius*e.radius/2:(2*e.radius)**2,style:e.style,datum:e.datum,accessibleDatum:e.datum,accessibility:{label:e.label,tableFields:{name:e.datum.name??e.label,label:e.label,row:e.row,column:e.column,...e.category?{category:e.category}:{}}},group:e.category,interactive:!0};var t,o,n}),overlays:!1===t.showLabels?null:We(Ge,{marks:A,color:t.labelColor??"#ffffff",fontSize:t.labelFontSize??Be(.23*Math.min(p,f),7,14),fontFamily:t.labelFontFamily,fontWeight:t.labelFontWeight??700}),restyle:(e,t)=>t?.isActive&&e.datum?{opacity:t.predicate(e.datum)?1:.18}:{opacity:1}}};function Ge({marks:e,color:t,fontSize:o,fontFamily:n,fontWeight:i}){const r=m();return We("g",{"aria-hidden":"true",pointerEvents:"none",children:e.map(e=>{const a=!r.isActive||r.predicate(e.datum);return We("text",{x:e.x,y:e.y,fill:t,fontFamily:n,fontSize:o,fontWeight:i,opacity:a?1:.18,textAnchor:"middle",dominantBaseline:"central",children:e.label},e.id)})})}import{geoBounds as qe,geoContains as _e}from"d3-geo";import{jsx as Ke}from"react/jsx-runtime";var Je=new WeakMap,Qe=new WeakMap,Ye=new WeakMap,Ve=1;function Xe(e,t,o){return Math.max(t,Math.min(o,e))}function et(e){if(Number.isFinite(e)&&Number(e)>0)return Number(e)}function tt(e,t){return"function"==typeof t?t(e,e.dotIndex):"string"==typeof t?e[t]:void 0}function ot(e){return e.properties&&"object"==typeof e.properties?{...e.properties}:{}}function nt(e,t){const o=ot(e);return(e.id??o.id??o.name??"feature-"+t)+""}function it(e,t,o,n){return[Math.ceil((e-o)/n-.5),Math.floor((t-o)/n-.5)]}function rt(e){if(!e)return 0;const t=Ye.get(e);if(t)return t;const o=Ve;return Ve+=1,Ye.set(e,o),o}function at(e,t){return!t||!(t[0][1]>e[1]||e[1]>t[1][1]||(o=e[0],n=t[0][0],i=t[1][0],n>i?n>o&&o>i:n>o||o>i));var o,n,i}function lt(e,t){for(const o of e){const{feature:e,index:n}=o;if(e.geometry&&at(t,o.bounds))try{if(_e(e,t))return{feature:e,index:n}}catch{}}return null}function st(e,t,o,n={}){const i=e.filter((e,t)=>e.geometry&&(!n.featureFilter||n.featureFilter(e,t))),r=function(e,t){if(0===e.length)return null;const o=t.bounds({type:"FeatureCollection",features:e});return Number.isFinite(o[0][0])&&Number.isFinite(o[0][1])&&Number.isFinite(o[1][0])&&Number.isFinite(o[1][1])?o:null}(i,t.geoPath);if(!r)return{dots:[],cellSize:10,features:i};const a=Math.max(0,n.layoutPadding??0),l=[[Xe(r[0][0],a,Math.max(a,o.width-a)),Xe(r[0][1],a,Math.max(a,o.height-a))],[Xe(r[1][0],a,Math.max(a,o.width-a)),Xe(r[1][1],a,Math.max(a,o.height-a))]],s=Math.max(0,l[1][0]-l[0][0]),c=Math.max(0,l[1][1]-l[0][1]);if(0===s||0===c)return{dots:[],cellSize:10,features:i};const u=et(n.columns);let d=Math.max(2,u?s/u:et(n.cellSize)??10);const m=Math.max(100,Math.round(et(n.maxSamples)??25e3)),h=Math.ceil(s/d)*Math.ceil(c/d);h>m&&(d*=Math.sqrt(h/m));const p=n.gridOrigin?.[0]??0,f=n.gridOrigin?.[1]??0,[y,g]=it(l[0][0],l[1][0],p,d),[b,v]=it(l[0][1],l[1][1],f,d),k=[],x=function(e){return e.map((e,t)=>{if(Qe.has(e))return{feature:e,index:t,bounds:Qe.get(e)??null};try{const o=qe(e);return Qe.set(e,o),{feature:e,index:t,bounds:o}}catch{return Qe.set(e,null),{feature:e,index:t,bounds:null}}})}(i);for(let e=b;v>=e;e+=1){const o=f+(e+.5)*d;for(let i=y;g>=i;i+=1){const r=t.invertedPoint(p+(i+.5)*d,o);if(!r||!Number.isFinite(r[0])||!Number.isFinite(r[1]))continue;const a=lt(x,r);if(!a)continue;const l={...ot(a.feature),featureId:nt(a.feature,a.index),featureIndex:a.index,gridRow:e,gridColumn:i,longitude:r[0],latitude:r[1],dotIndex:k.length};n.dotFilter&&!n.dotFilter(l,k.length)||k.push(l)}}return{dots:k,cellSize:d,features:i}}function ct(e){return Math.round(1e4*e)/1e4}function ut(e){return Array.isArray(e)&&e.length>=2&&Number.isFinite(e[0])&&Number.isFinite(e[1])?`${ct(Number(e[0]))},${ct(Number(e[1]))}`:"null"}function dt(e,t){const o=e[t];return"function"==typeof o?o.call(e):void 0}function mt(e){return"number"==typeof e&&Number.isFinite(e)?ct(e)+"":null===e?"null":"unavailable"}function ht(e){const t=e.scales.projection;return[mt(dt(t,"scale")),ut(dt(t,"translate")),ut(dt(t,"center")),(o=dt(t,"rotate"),Array.isArray(o)&&o.every(Number.isFinite)?o.map(e=>ct(Number(e))).join(","):"unavailable"),mt(dt(t,"clipAngle")),mt(dt(t,"precision")),...[[0,0],[-120,35],[45,45],[120,-30]].map(([t,o])=>ut(e.scales.projectedPoint(t,o)))].join("|");var o}function pt(e){return e.map(([e,t],o)=>`${0===o?"M":"L"}${e},${t}`).join("")+"Z"}var ft=e=>{const t=function(e){let t=Je.get(e.areas);t||(t=new Map,Je.set(e.areas,t));const o=function(e){const t=e.config;return[e.areas.length,e.dimensions.width,e.dimensions.height,t.cellSize??"",t.columns??"",t.layoutPadding??"",t.gridOrigin?.join(",")??"",t.maxSamples??"",rt(t.featureFilter),rt(t.dotFilter),ht(e)].join("::")}(e),n=t.get(o);if(n)return n;const i=st(e.areas,e.scales,e.dimensions,e.config);if(t.size>=12){const e=t.keys().next().value;void 0!==e&&t.delete(e)}return t.set(o,i),i}(e),o=e.config,n=o.shape??"circle",i=Math.max(.5,et(o.dotRadius)??t.cellSize*Xe(o.radiusRatio??.24,.05,.5)),r=o.gridOrigin?.[0]??0,a=o.gridOrigin?.[1]??0;return{nodes:t.dots.map((l,s)=>{const c=r+(l.gridColumn+.5)*t.cellSize,u=a+(l.gridRow+.5)*t.cellSize,d=tt(l,o.categoryAccessor),m=tt(l,o.fillAccessor),h={fill:null!=m?m+"":null!=d?e.resolveColor(d+""):e.theme.categorical[0]??"#4f86c6",fillOpacity:.92,strokeWidth:0,..."function"==typeof o.markStyle?o.markStyle(l,s):o.markStyle},p=`dot-${l.gridRow}-${l.gridColumn}`;if("circle"===n)return{type:"point",x:c,y:u,r:i,style:h,datum:l,interactive:!1,pointId:p,_transitionKey:p};const f="hexagon"===n?function(e,t,o){return pt(Array.from({length:6},(n,i)=>{const r=-Math.PI/2+i*(Math.PI/3);return[e+Math.cos(r)*o,t+Math.sin(r)*o]}))}(c,u,i):function(e,t,o){return pt([[e-o,t-o],[e+o,t-o],[e+o,t+o],[e-o,t+o]])}(c,u,i);return{type:"geoarea",pathData:f,centroid:[c,u],bounds:[[c-i,u-i],[c+i,u+i]],screenArea:"hexagon"===n?3*Math.sqrt(3)*i*i/2:(2*i)**2,style:h,datum:l,group:l.featureId,interactive:!1}}),overlays:o.showOutline?Ke("g",{"aria-hidden":"true",pointerEvents:"none",children:t.features.map((t,n)=>{const i=e.scales.geoPath(t);return i?Ke("path",{d:i,fill:"none",stroke:o.outlineStyle?.stroke??"currentColor",strokeOpacity:o.outlineStyle?.opacity??o.outlineStyle?.fillOpacity??.22,strokeWidth:o.outlineStyle?.strokeWidth??.7,strokeDasharray:o.outlineStyle?.strokeDasharray,strokeLinecap:o.outlineStyle?.strokeLinecap,vectorEffect:"non-scaling-stroke"},nt(t,n)):null})}):null,restyle:(e,t)=>t?.isActive&&e.datum?{opacity:t.predicate(e.datum)?1:.14}:{opacity:1}}};function yt(e,t,o){const{featureKey:n,dataKey:i}=o,r=new Map;for(const e of t)r.set(e[i]+"",e);return e.map(e=>{const t=(e=>{const t=n.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})}export{ae as ChoroplethMap,e as DEFAULT_HIT_RADIUS,Le as DistanceCartogram,Ae as FlowMap,i as GeoCustomChart,fe as ProportionalSymbolMap,r as StreamGeoFrame,h as composeStyleRules,t as geoAreaHitTarget,o as geoHitTarget,ft as geographicDotGridLayout,Ze as geographicGridLayout,E as glyphExtent,$ as glyphPlacement,Ee as gridifyGeographicPoints,A as hatchFillId,C as hatchPatternDef,n as hitTargetPoint,N as isHatchFill,p as makeNodeRuleContext,f as makeRuleValueResolver,y as matchesThreshold,yt as mergeData,oe as resolveReferenceGeography,H as resolveResponsiveRules,g as resolveStyleRules,I as resolveSvgFill,P as responsiveRuleMatches,b as ruleMatches,st as sampleGeographicDotGrid};
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-G2RGVEYY.module.min.js";import{mergeShapeStyle as a,normalizePartialMargin as l,useChartSetup as s,useFrameImperativeHandle as c,useResolvedSelection as u}from"./chunk-chunk-MXMRXSCI.module.min.js";import"./chunk-chunk-XECNOUZY.module.min.js";import"./chunk-chunk-VKL6DI43.module.min.js";import"./chunk-chunk-DTH3SUOU.module.min.js";import{buildCustomBehaviorProps as m}from"./chunk-chunk-DVCWU7MT.module.min.js";import{useCustomLayoutSelection as d}from"./chunk-chunk-5UKL5W76.module.min.js";import"./chunk-chunk-XYZDTYAF.module.min.js";import{composeStyleRules as h,makeNodeRuleContext as p,makeRuleValueResolver as f,matchesThreshold as y,resolveStyleRules as g,ruleMatches as b}from"./chunk-chunk-EMO5NUGE.module.min.js";import"./chunk-chunk-OHLRAEQZ.module.min.js";import"./chunk-chunk-AFQHURLO.module.min.js";import{DEFAULT_COLOR as v,EMPTY_ARRAY as k,filterSparseArray as x,getColor as w,getSequentialInterpolator as S,getSize as M,hatchFillId as A,hatchPatternDef as C,isHatchFill as R,normalizeLinkedHover as N,normalizeTooltip as F,resolveAxisFreeMarginDefaults as j,resolveResponsiveRules as P,resolveSvgFill as I,responsiveRuleMatches as H,useChartMode as z,useChartSelection as L,useLinkedHover as W,useObservationSelector as D,useThemeSequential as O,wrapStyleWithSelection as T}from"./chunk-chunk-SK2TQMG4.module.min.js";import{getMinMax as E}from"./chunk-chunk-2NVFEB7P.module.min.js";import"./chunk-chunk-PMR47KRY.module.min.js";import{glyphExtent as B,glyphPlacement as $}from"./chunk-chunk-KTWEBFMX.module.min.js";import{ChartError as U,SafeRender as Z,renderEmptyState as G,renderLoadingState as q,warnMissingField as K}from"./chunk-chunk-ACLDBMRH.module.min.js";import"./chunk-chunk-YHNZCPOZ.module.min.js";import{useMemo as _}from"react";import{scaleSequential as Y}from"d3-scale";import{useState as X,useEffect as V,useMemo as J}from"react";import{feature as Q}from"topojson-client";var ee=new Map;function te(e){return"default"in e?e.default:e}async function oe(e){const t=ee.get(e);if(t)return t;const{topology:o,objectName:i}=await async function(e){try{switch(e){case"world-110m":return{topology:te(await import("world-atlas/countries-110m.json")),objectName:"countries"};case"world-50m":return{topology:te(await import("world-atlas/countries-50m.json")),objectName:"countries"};case"land-110m":return{topology:te(await import("world-atlas/land-110m.json")),objectName:"land"};case"land-50m":return{topology:te(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=Q(o,o.objects[i]),r="features"in n?n.features:[n];return ee.set(e,r),r}function ie(e){const t=J(()=>Array.isArray(e)?e:void 0,[e]),[o,i]=X(null);return V(()=>{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),oe(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 ne,jsxs as re}from"react/jsx-runtime";function ae(e){const t=z(e.mode,{width:e.width,height:e.height,showLegend:e.showLegend,enableHover:e.enableHover,linkedHover:e.linkedHover,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),o=O(),{areas:i,valueAccessor:n,styleRules:s,colorScheme:c,projection:d="equalEarth",graticule:p,fitPadding:f,zoomable:y,zoomExtent:g,onZoom:b,dragRotate:v,tileURL:k,tileAttribution:w,tileCacheSize:M,tooltip:A,areaOpacity:C=1,annotations:R,margin:N,className:P,selection:I,linkedHover:H,onObservation:W,onClick:D,chartId:E,loading:B,loadingContent:$,emptyContent:K,frameProps:X={},stroke:V,strokeWidth:J,opacity:Q}=e,ee=y??!!k,te=ie(i),oe=_(()=>te?x(te):te,[te]),ae=_(()=>"function"==typeof n?n:e=>e?.properties?.[n]??e?.[n],[n]),le=c??o??"blues",se=_(()=>{if(!oe)return Y(S(void 0)).domain([0,1]);let e=1/0,t=-1/0;for(const o of oe){const i=ae(o);null!=i&&isFinite(i)&&(e>i&&(e=i),i>t&&(t=i))}const o=S(le);return Y(o).domain([Number.isFinite(e)?e:0,Number.isFinite(t)?t:1])},[oe,ae,le]),{activeSelectionHook:ce,customHoverBehavior:ue,customClickBehavior:me}=L({selection:I,linkedHover:H,onObservation:W,onClick:D,chartType:"ChoroplethMap",chartId:E,mobileInteraction:t.mobileInteraction}),de=u(I),he=_(()=>{const e=h(e=>{const t=ae(e);return{fill:null!=t&&isFinite(t)?se(t):"#ccc",stroke:"#999",strokeWidth:.5,fillOpacity:C}},s,e=>({value:ae(e)}),e=>e&&"object"==typeof e&&e.properties?{...e.properties,...e}:e),t=a(e,{stroke:V,strokeWidth:J,opacity:Q});return ce?T(t,ce,de):t},[ae,se,ce,de,C,V,J,Q,s]),pe=_(()=>e=>{const t=e?.properties?.name||e?.properties?.NAME||e?.name||e?.NAME||"Feature",o=ae(e);return re("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12},children:[ne("div",{style:{fontWeight:600},children:t}),null!=o&&ne("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},[ae]),fe=j(t),ye=_(()=>({...fe,...l(N)}),[fe,N]),ge=q(B,t.width,t.height,$)||(oe?null:q(!0,t.width,t.height,$)),be=ge?null:G(oe,t.width,t.height,K);if(Array.isArray(oe)&&oe.length>0){const e=oe[0];if(!e||"object"!=typeof e||!e.geometry)return ne(U,{componentName:"ChoroplethMap",message:"ChoroplethMap: areas must be an array of GeoJSON Features with a geometry property.",width:t.width,height:t.height})}const ve={projection:d,areas:oe,areaStyle:he,size:[t.width,t.height],maxDevicePixelRatio:e.maxDevicePixelRatio,margin:ye,enableHover:t.enableHover,tooltipContent:!1===A?()=>null:!0===A?pe:F(A)||pe,...null!=p&&{graticule:p},...null!=f&&{fitPadding:f},...ee&&{zoomable:!0},...g&&{zoomExtent:g},...b&&{onZoom:b},...null!=v&&{dragRotate:v},...k&&{tileURL:k},...w&&{tileAttribution:w},...M&&{tileCacheSize:M},...m({linkedHover:H,selection:I,onObservation:W,onClick:D,mobileInteraction:t.mobileInteraction,customHoverBehavior:ue,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},...P&&{className:P},...null!=e.animate&&{animate:e.animate},...X};return ge||be||ne(Z,{componentName:"ChoroplethMap",width:t.width,height:t.height,children:ne(r,{...ve})})}ae.displayName="ChoroplethMap";import{useMemo as le,useRef as se,forwardRef as ce}from"react";var ue={fill:"#f0f0f0",stroke:"#ccc",strokeWidth:.5};import{jsx as me,jsxs as de}from"react/jsx-runtime";var he=[3,30],pe=[1,4],fe=ce(function(e,t){const o=se(null);c(t,{variant:"geo-points",frameRef:o});const i=z(e.mode,{width:e.width,height:e.height,showLegend:e.showLegend,enableHover:e.enableHover,linkedHover:e.linkedHover,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:u="lat",sizeBy:d,sizeRange:f,colorBy:y,styleRules:g,colorScheme:b,projection:x="equalEarth",graticule:S,fitPadding:A,zoomable:C,zoomExtent:R,onZoom:N,dragRotate:P,tileURL:I,tileAttribution:H,tileCacheSize:L,areas:W,areaStyle:D=ue,tooltip:O,annotations:B,margin:$,className:U,selection:G,linkedHover:q,onObservation:_,onClick:Y,chartId:X,loading:V,loadingContent:J,emptyContent:Q,legendInteraction:ee,legendPosition:te,frameProps:oe={},stroke:ne,strokeWidth:re,opacity:ae}=e,ce=f??("sparkline"===i.mode?pe:he),fe="sparkline"===i.mode?1.5:6,ye=C??!!I,ge=ie(W),be=s({data:n??k,rawData:n,colorBy:y,colorScheme:b,legendInteraction:ee,legendPosition:te,selection:G,linkedHover:q,fallbackFields:y?["string"==typeof y?y:""]:[],unwrapData:!1,onObservation:_,onClick:Y,mobileInteraction:i.mobileInteraction,mobileSemantics:i.mobileSemantics,chartType:"ProportionalSymbolMap",chartId:X,showLegend:i.showLegend,userMargin:$,marginDefaults:j(i),loading:V,loadingContent:J,emptyContent:Q,width:i.width,height:i.height,hasTitle:!!i.title}),ve=be.data,ke=le(()=>{if(!d)return;const e="function"==typeof d?d:e=>e?.[d],t=ve.filter(Boolean).map(t=>e(t)).filter(e=>null!=e&&isFinite(e));return 0!==t.length?E(t):void 0},[ve,d]),xe=le(()=>{const e=h(e=>({fill:y?w(e,y,be.colorScale):v,fillOpacity:.7,stroke:"#fff",strokeWidth:.5,r:d?M(e,d,ce,ke):fe}),g,p(y,d)),t=a(e,{stroke:ne,strokeWidth:re,opacity:ae});return be.effectiveSelectionHook?T(t,be.effectiveSelectionHook,be.resolvedSelection):t},[y,be.colorScale,be.effectiveSelectionHook,be.resolvedSelection,d,ce,ke,fe,ne,re,ae,g]),we=le(()=>e=>{const t=e?.name||e?.label||e?.NAME||e?.id,o="string"==typeof d?d:null,i=("function"==typeof d?d:e=>e[d])(e),n=e=>"number"==typeof e&&isFinite(e)?Number.isInteger(e)?e.toLocaleString():e.toLocaleString(void 0,{maximumFractionDigits:2}):(e??"")+"",r="string"==typeof y?y:null,a=r?e?.[r]:null;return de("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12},children:[t&&me("div",{style:{fontWeight:600,marginBottom:2},children:t}),o&&null!=i&&de("div",{children:[de("span",{style:{opacity:.7},children:[o,": "]}),n(i)]}),r&&null!=a&&de("div",{children:[de("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])=>de("div",{children:[de("span",{style:{opacity:.7},children:[e,": "]}),n(t)]},e))]})},[d,y]);if(be.earlyReturn)return be.earlyReturn;K("ProportionalSymbolMap",ve,"xAccessor",l),K("ProportionalSymbolMap",ve,"yAccessor",u);const Se={projection:x,...null!=n&&{points:ve},xAccessor:l,yAccessor:u,pointStyle:xe,...e.pointIdAccessor&&{pointIdAccessor:e.pointIdAccessor},...ge&&{areas:ge,areaStyle:D},...null!=S&&{graticule:S},...null!=A&&{fitPadding:A},...ye&&{zoomable:!0},...R&&{zoomExtent:R},...N&&{onZoom:N},...null!=P&&{dragRotate:P},...I&&{tileURL:I},...H&&{tileAttribution:H},...L&&{tileCacheSize:L},size:[i.width,i.height],maxDevicePixelRatio:e.maxDevicePixelRatio,margin:be.margin,enableHover:i.enableHover,tooltipContent:!1===O?()=>null:F(O)||we,...be.legendBehaviorProps,...m({linkedHover:q,selection:G,onObservation:_,onClick:Y,mobileInteraction:be.mobileInteraction,customHoverBehavior:be.customHoverBehavior,customClickBehavior:be.customClickBehavior,linkedHoverInClickPredicate:!1}),...B&&B.length>0&&{annotations:B},...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},...U&&{className:U},...null!=e.animate&&{animate:e.animate},...oe};return me(Z,{componentName:"ProportionalSymbolMap",width:i.width,height:i.height,children:me(r,{ref:o,...Se})})});fe.displayName="ProportionalSymbolMap";import{useMemo as ye,useCallback as ge,useRef as be,forwardRef as ve}from"react";import{scaleLinear as ke}from"d3-scale";import{jsx as xe,jsxs as we}from"react/jsx-runtime";var Se="__semiotic_x",Me="__semiotic_y",Ae=ve(function(e,t){const o=z(e.mode,{width:e.width,height:e.height,showLegend:e.showLegend,enableHover:e.enableHover,linkedHover:e.linkedHover,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:u="lon",yAccessor:d="lat",valueAccessor:h="value",projection:p="equalEarth",graticule:f,fitPadding:y,zoomable:g,zoomExtent:b,onZoom:S,dragRotate:M,tileURL:A,tileAttribution:C,tileCacheSize:R,lineType:P="geo",flowStyle:I="basic",areas:H,areaStyle:L=ue,edgeColorBy:O,edgeOpacity:B=.6,edgeWidthRange:$=[1,8],pointRadius:U,edgeLinecap:G="round",colorScheme:q,showParticles:K,particleStyle:_,tooltip:Y,annotations:X,margin:V,className:J,selection:Q,linkedHover:ee,onObservation:te,onClick:oe,chartId:ne,loading:re,loadingContent:ae,emptyContent:le,frameProps:se={},legendInteraction:ce,legendPosition:me,stroke:de,strokeWidth:he,opacity:pe,lineIdAccessor:fe}=e,ve=g??!!A,Ae=ie(H),Ce=ye(()=>x(n),[n]),Re=s({data:i??k,rawData:i,colorBy:O,colorScheme:q,legendInteraction:ce,legendPosition:me,selection:Q,linkedHover:ee,fallbackFields:O?["string"==typeof O?O:""]:[],unwrapData:!1,onObservation:te,onClick:oe,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"FlowMap",chartId:ne,showLegend:o.showLegend,userMargin:V,marginDefaults:j(o),loading:re,loadingContent:ae,emptyContent:le,width:o.width,height:o.height,hasTitle:!!o.title}),Ne=Re.data,Fe=N(ee),je=W({name:Fe?.name||"hover",fields:Fe?.fields||[]}),Pe=D(e=>e.pushObservation),Ie=ye(()=>{const e=new Map;for(const t of Ce)e.set(t[l]+"",t);return e},[Ce,l]),He=be(null),ze=be(Ie);ze.current=Ie;const Le=be(u);Le.current=u;const We=be(d);We.current=d;const De=ge(e=>{if(!e||"object"!=typeof e||null==e.source||null==e.target)return null;const t=ze.current,o=t.get(e.source+""),i=t.get(e.target+"");if(!o||!i)return null;const n="function"==typeof Le.current?Le.current:e=>e[Le.current],r="function"==typeof We.current?We.current:e=>e[We.current];return{...e,coordinates:[{[Se]:n(o),[Me]:r(o)},{[Se]:n(i),[Me]:r(i)}]}},[]);c(t,{variant:"geo-lines",frameRef:He,overrides:{push:e=>{const t=De(e);t&&He.current?.pushLine(t)},pushMany:e=>{const t=[];for(const o of e){const e=De(o);e&&t.push(e)}t.length>0&&He.current?.pushManyLines(t)}}});const Oe=ye(()=>{const e=new Map;for(const t of Ne)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},[Ne]),Te=ge(e=>{if(ee)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"point"===e.type){const e=Oe.get(t[l]+"");e&&je.onHover(e)}else je.onHover(t)}else je.onHover(null);if(te||Pe){const t={timestamp:Date.now(),chartType:"FlowMap",chartId:ne};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};te&&te(i),Pe&&Pe(i)}else{const e={...t,type:"hover-end"};te&&te(e),Pe&&Pe(e)}}},[ee,je,l,Oe,te,ne,Pe]),Ee=Re.customClickBehavior,Be=ye(()=>{const e="function"==typeof u?u:e=>e[u],t="function"==typeof d?d:e=>e[d];return Ne.map(o=>{if(!o||"object"!=typeof o||null==o.source||null==o.target)return null;const i=Ie.get(o.source+""),n=Ie.get(o.target+"");return i&&n?{...o,coordinates:[{[Se]:e(i),[Me]:t(i)},{[Se]:e(n),[Me]:t(n)}]}:null}).filter(Boolean)},[Ne,Ie,u,d]),$e=ye(()=>{const e="function"==typeof u?u:e=>e[u];return t=>null!=t&&"object"==typeof t&&Se in t?t[Se]:e(t)},[u]),Ue=ye(()=>{const e="function"==typeof d?d:e=>e[d];return t=>null!=t&&"object"==typeof t&&Me in t?t[Me]:e(t)},[d]),Ze=ye(()=>{const e=Ne.filter(e=>e&&"object"==typeof e).map(e=>e[h]??0).filter(e=>isFinite(e));return 0===e.length?()=>$[0]:ke().domain(E(e)).range($)},[Ne,h,$]),Ge=ye(()=>e=>({stroke:O?w(e,O,Re.colorScale):v,strokeWidth:Ze(e[h]??0),strokeLinecap:G,opacity:B}),[O,Re.colorScale,Ze,h,B,G]),qe=ye(()=>{const e=a(Ge,{stroke:de,strokeWidth:he,opacity:pe});if(!Re.effectiveSelectionHook)return e;const t={...Re.resolvedSelection?.unselectedStyle||{},fillOpacity:0};return T(e,Re.effectiveSelectionHook,{...Re.resolvedSelection||{},unselectedStyle:t})},[Ge,Re.effectiveSelectionHook,Re.resolvedSelection,de,he,pe]),Ke=U??("sparkline"===o.mode?1.5:5),_e=ye(()=>a(()=>({fill:"#333",r:Ke,fillOpacity:.8}),{stroke:de,strokeWidth:he,opacity:pe}),[Ke,de,he,pe]),Ye=ye(()=>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 xe("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12},children:xe("div",{style:{fontWeight:600},children:t})})}if(null!=e?.source&&null!=e?.target){const t=e[h];return we("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12},children:[we("div",{style:{fontWeight:600},children:[e.source," → ",e.target]}),null!=t&&xe("div",{style:{opacity:.7},children:"number"==typeof t?t.toLocaleString():t})]})}const t=e?.name||e?.label||e?.[l];return null!=t?xe("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12},children:xe("div",{style:{fontWeight:600},children:t})}):null},[h,l]);if(Re.earlyReturn)return Re.earlyReturn;const Xe={projection:p,...null!=i&&{lines:Be},points:Ce,xAccessor:$e,yAccessor:Ue,lineDataAccessor:"coordinates",...null!=fe&&{lineIdAccessor:fe},lineType:P,flowStyle:I,lineStyle:qe,pointStyle:_e,...Ae&&{areas:Ae,areaStyle:L},...null!=f&&{graticule:f},...null!=y&&{fitPadding:y},...ve&&{zoomable:!0},...b&&{zoomExtent:b},...S&&{onZoom:S},...null!=M&&{dragRotate:M},...K&&{showParticles:K},..._&&{particleStyle:_},...A&&{tileURL:A},...C&&{tileAttribution:C},...R&&{tileCacheSize:R},size:[o.width,o.height],maxDevicePixelRatio:e.maxDevicePixelRatio,margin:Re.margin,enableHover:o.enableHover,tooltipContent:!1===Y?()=>null:F(Y)||Ye,...Re.legendBehaviorProps,...m({linkedHover:ee,selection:Q,onObservation:te,onClick:oe,mobileInteraction:Re.mobileInteraction,customHoverBehavior:Te,customClickBehavior:Ee,linkedHoverInClickPredicate:!1}),...X&&X.length>0&&{annotations:X},...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},...J&&{className:J},...null!=e.animate&&{animate:e.animate},...se};return xe(Z,{componentName:"FlowMap",width:o.width,height:o.height,children:xe(r,{ref:He,...Xe})})});Ae.displayName="FlowMap";import{useMemo as Ce,useRef as Re,useState as Ne,useEffect as Fe,useCallback as je,forwardRef as Pe}from"react";import{Fragment as Ie,jsx as He,jsxs as ze}from"react/jsx-runtime";var Le=Pe(function(e,t){const o=z(e.mode,{width:e.width,height:e.height,showLegend:e.showLegend,enableHover:e.enableHover,linkedHover:e.linkedHover,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:u="lat",nodeIdAccessor:d="id",center:f,costAccessor:y,strength:g=1,lineMode:b="straight",projection:k="mercator",graticule:S,fitPadding:M,zoomable:A,zoomExtent:C,onZoom:R,dragRotate:N,tileURL:P,tileAttribution:I,tileCacheSize:H,transition:L,colorBy:W,styleRules:D,colorScheme:O,pointRadius:E,tooltip:B,showRings:$,showRingLabels:U,ringStyle:G,showNorth:q,costLabel:_,cartogramLayout:Y,annotations:X,margin:V,className:J,selection:Q,linkedHover:ee,onObservation:te,onClick:oe,chartId:ie,loading:ne,loadingContent:re,emptyContent:ae,legendPosition:le,frameProps:se={},stroke:ce,strokeWidth:ue,opacity:me}=e,de="sparkline"===o.mode,he=Y??(de?"strip":"radial"),pe=E??(de?1.5:5),fe=$??!0,ye=U??("strip"!==he&&!o.compactMode),ge=q??("strip"!==he&&!de),be=A??!!P,ve=Ce(()=>x(i),[i]),ke=s({data:ve,rawData:i,colorBy:W,colorScheme:O,legendInteraction:void 0,legendPosition:le,selection:Q,linkedHover:ee,fallbackFields:W?["string"==typeof W?W:""]:[],unwrapData:!1,onObservation:te,onClick:oe,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"DistanceCartogram",chartId:ie,showLegend:o.showLegend,userMargin:V,marginDefaults:j(o),loading:ne,loadingContent:re,emptyContent:ae,width:o.width,height:o.height,hasTitle:!!o.title}),xe=Ce(()=>{const e=h(e=>{const t=e?.[d],o=null!=t&&t+""==f+"";return{fill:W?w(e,W,ke.colorScale):v,fillOpacity:o?1:.8,stroke:o?"var(--semiotic-text, #222)":"#fff",strokeWidth:o?1.25:1,r:o?1.35*pe:pe}},D,p(W)),t=a(e,{stroke:ce,strokeWidth:ue,opacity:me});return ke.effectiveSelectionHook?T(t,ke.effectiveSelectionHook,ke.resolvedSelection):t},[W,ke.colorScale,ke.effectiveSelectionHook,ke.resolvedSelection,pe,ce,ue,me,D,f,d]),we=Ce(()=>({center:f,centerAccessor:d,costAccessor:y,strength:g,lineMode:b,layout:he}),[f,d,y,g,b,he]),Se=Ce(()=>{if(!n)return;const e="function"==typeof l?l:e=>e[l],t="function"==typeof u?u:e=>e[u],o=new Map;for(const e of ve)o.set(e[d]+"",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),[u]:t(n)},{[l]:e(r),[u]:t(r)}]}:null}).filter(Boolean)},[n,ve,l,u,d]),Me=Ce(()=>e=>{const t=("function"==typeof y?y:e=>e[y])(e);return ze("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12},children:[He("div",{style:{fontWeight:600},children:e[d]||e.name||e.id||"Point"}),null!=t&&ze("div",{style:{opacity:.7},children:["Cost: ","number"==typeof t?t.toFixed(1):t]})]})},[y,d]),Ae=Re(null);c(t,{variant:"geo-points",frameRef:Ae});const[Pe,Le]=Ne(null),We=je(()=>{const e=Ae.current?.getCartogramLayout?.();e&&Le(t=>t&&t.cx===e.cx&&t.cy===e.cy&&t.maxCost===e.maxCost&&t.availableRadius===e.availableRadius&&t.layout===(e.layout??"radial")?t:{cx:e.cx,cy:e.cy,maxCost:e.maxCost,availableRadius:e.availableRadius,layout:e.layout??"radial"})},[]);Fe(()=>{const e=requestAnimationFrame(We);return()=>cancelAnimationFrame(e)},[We,g,f,o.width,o.height,ve,he]);const De=Ce(()=>{if(!fe||!Pe)return[];const{maxCost:e}=Pe;if(0>=e)return[];if(Array.isArray(fe))return fe.filter(t=>t>0&&e>=t);const t="number"==typeof fe?fe:Math.min("strip"===Pe.layout?3: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},[fe,Pe]),Oe=Ce(()=>{if(!Pe)return se.foregroundGraphics||null;const{cx:e,cy:t,maxCost:o,availableRadius:i,layout:n}=Pe,r="strip"===n,a={stroke:r?"var(--semiotic-border, #999)":"#999",strokeWidth:r?1:.8,strokeDasharray:r?"none":"4,3",labelColor:"var(--semiotic-text-secondary, #777)",labelSize:r?8:10,...G},l=ke.margin.left??10,s=ke.margin.top??10,c=e+l,u=t+s;return ze("g",{children:[ze(Ie,r?{children:[He("line",{x1:c,y1:u,x2:c+i,y2:u,stroke:a.stroke,strokeWidth:a.strokeWidth,strokeLinecap:"round",opacity:.85}),He("line",{x1:c,y1:u-3.5,x2:c,y2:u+3.5,stroke:a.stroke,strokeWidth:a.strokeWidth,opacity:.9}),fe&&De.map(e=>{const t=c+(o>0?e/o*i:0);return ze("g",{children:[He("line",{x1:t,y1:u-2.5,x2:t,y2:u+2.5,stroke:a.stroke,strokeWidth:.9,opacity:.65}),ye&&ze("text",{x:t,y:u+Math.min(10,(ke.margin.bottom??2)+8),textAnchor:"middle",fontSize:a.labelSize,fill:a.labelColor,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",children:[e,_?" "+_:""]})]},e)})]}:{children:[De.map(e=>{const t=e/o*i;return ze("g",{children:[He("circle",{cx:c,cy:u,r:t,fill:"none",stroke:a.stroke,strokeWidth:a.strokeWidth,strokeDasharray:a.strokeDasharray,opacity:.5}),ye&&ze("text",{x:c+t+3,y:u-2,fontSize:a.labelSize,fill:a.labelColor,fontFamily:"system-ui, sans-serif",children:[e,_?" "+_:""]})]},e)}),ge&&ze("g",{transform:`translate(${l+24}, ${s+24})`,children:[He("circle",{r:16,fill:"white",fillOpacity:.85,stroke:"#bbb",strokeWidth:.8}),He("path",{d:"M0,-11 L3,-3 L1,-4 L1,7 L-1,7 L-1,-4 L-3,-3 Z",fill:"#555",stroke:"none"}),He("text",{y:-12,textAnchor:"middle",fontSize:7,fontWeight:700,fill:"#555",fontFamily:"system-ui, sans-serif",children:"N"}),He("line",{x1:11,y1:0,x2:13,y2:0,stroke:"#bbb",strokeWidth:.8}),He("line",{x1:-11,y1:0,x2:-13,y2:0,stroke:"#bbb",strokeWidth:.8}),He("line",{x1:0,y1:11,x2:0,y2:13,stroke:"#bbb",strokeWidth:.8})]})]}),se.foregroundGraphics]})},[Pe,De,fe,ye,ge,_,G,ke.margin,se.foregroundGraphics]);if(ke.earlyReturn)return ke.earlyReturn;K("DistanceCartogram",ve,"xAccessor",l),K("DistanceCartogram",ve,"yAccessor",u);const Te={projection:k,...null!=i&&{points:ve},...Se&&{lines:Se,lineDataAccessor:"coordinates"},xAccessor:l,yAccessor:u,pointIdAccessor:d,pointStyle:xe,projectionTransform:we,...L&&{transition:{duration:L}},...null!=S&&{graticule:S},...null!=M&&{fitPadding:M},...be&&{zoomable:!0},...C&&{zoomExtent:C},...R&&{onZoom:R},...null!=N&&{dragRotate:N},...P&&{tileURL:P},...I&&{tileAttribution:I},...H&&{tileCacheSize:H},size:[o.width,o.height],maxDevicePixelRatio:e.maxDevicePixelRatio,margin:ke.margin,enableHover:o.enableHover,tooltipContent:!1===B?()=>null:F(B)||Me,...ke.legendBehaviorProps,...m({linkedHover:ee,selection:Q,onObservation:te,onClick:oe,mobileInteraction:ke.mobileInteraction,customHoverBehavior:ke.customHoverBehavior,customClickBehavior:ke.customClickBehavior,linkedHoverInClickPredicate:!1}),...X&&X.length>0&&{annotations:X},...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},...J&&{className:J},...null!=e.animate&&{animate:e.animate},...se,foregroundGraphics:Oe};return He(Z,{componentName:"DistanceCartogram",width:o.width,height:o.height,children:He(r,{ref:Ae,...Te})})});Le.displayName="DistanceCartogram";import{jsx as We}from"react/jsx-runtime";function De(e){if(Number.isFinite(e))return Math.max(1,Math.round(e))}function Oe(e,t,o){return Math.max(t,Math.min(o,e))}function Te(e){let t=1/0,o=-1/0;for(const i of e)Number.isFinite(i)&&(t>i&&(t=i),i>o&&(o=i));return t===1/0?[0,0]:[t,o]}function Ee(e,t){const o=t[1]-t[0];return 0===o?.5:(e-t[0])/o}function Be(e,t={}){const o=e.map((e,t)=>({...e,index:t})).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y));if(0===o.length)return[];const i=Oe(Number.isFinite(t.occupancy)?Number(t.occupancy):.72,.2,1),n=Number.isFinite(t.aspectRatio)&&Number(t.aspectRatio)>0?Number(t.aspectRatio):1.8;let r=De(t.columns)??Math.max(1,Math.ceil(Math.sqrt(o.length*n/i))),a=De(t.rows)??Math.max(1,Math.ceil(o.length/(r*i)));o.length>r*a&&(null!=t.columns&&null==t.rows?a=Math.ceil(o.length/r):null!=t.rows&&null==t.columns?r=Math.ceil(o.length/a):a=Math.ceil(o.length/r));const l=Te(o.map(e=>e.x)),s=Te(o.map(e=>e.y)),c=o.map(e=>({...e,desiredColumn:Ee(e.x,l)*Math.max(0,r-1),desiredRow:Ee(e.y,s)*Math.max(0,a-1)})),u=(r-1)/2,m=(a-1)/2;c.sort((e,t)=>(t.desiredColumn-u)**2+(t.desiredRow-m)**2-((e.desiredColumn-u)**2+(e.desiredRow-m)**2)||e.desiredRow-t.desiredRow||e.desiredColumn-t.desiredColumn||e.index-t.index);const d=new Set;for(let e=0;a>e;e+=1)for(let t=0;r>t;t+=1)d.add(e*r+t);const h=[];for(const e of c){let t=-1,o=1/0;for(const i of d){const n=(i%r-e.desiredColumn)**2+(Math.floor(i/r)-e.desiredRow)**2;(o>n||n===o&&t>i)&&(t=i,o=n)}0>t||(d.delete(t),h.push({datum:e.datum,x:e.x,y:e.y,row:Math.floor(t/r),column:t%r,index:e.index}))}return h.sort((e,t)=>e.index-t.index),h.map(({index:e,...t})=>t)}function $e(e,t,o=[]){if("function"==typeof t)return t(e);if("string"==typeof t)return e[t];for(const t of o)if(null!=e[t])return e[t]}function Ue(e){return e.map(([e,t],o)=>`${0===o?"M":"L"}${e},${t}`).join("")+"Z"}var Ze=e=>{const t=e.config,o=t.source??"auto",i="areas"===o||"auto"===o&&e.areas.length>0,n=i?function(e){return e.areas.map((t,o)=>{const i=function(e,t){const o=e.properties&&"object"==typeof e.properties?e.properties:{},i=e.id??o.id??o.name??"area-"+t;return{...o,id:i+""}}(t,o),n=e.scales.geoPath.centroid(t),r=Number.isFinite(n[0])&&Number.isFinite(n[1])?e.scales.invertedPoint(n[0],n[1]):null;return{datum:{...i,gridLongitude:r?.[0],gridLatitude:r?.[1]},x:n[0],y:n[1]}}).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y))}(e):e.points.map((e,t)=>({datum:e,x:t,y:t})),r=n.filter((e,o)=>!t.filter||t.filter(e.datum,o)),a=function(e,t){if(!t.rowAccessor||!t.columnAccessor)return null;const o=e.map(e=>({datum:e,x:Number($e(e,t.columnAccessor)),y:Number($e(e,t.rowAccessor))})).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y));return o.length!==e.length?null:o.map(e=>({...e,row:e.y,column:e.x}))}(r.map(e=>e.datum),t),l=i?r:function(e){return e.points.map(t=>{const o=Number($e(t,e.config.longitudeAccessor,["lon","longitude"])),i=Number($e(t,e.config.latitudeAccessor,["lat","latitude"])),n=Number.isFinite(o)&&Number.isFinite(i)?e.scales.projectedPoint(o,i):null;return{datum:t,x:n?.[0]??NaN,y:n?.[1]??NaN}}).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y))}({...e,points:r.map(e=>e.datum)}),s=a??Be(l,{columns:t.columns,rows:t.rows,occupancy:t.occupancy,aspectRatio:e.dimensions.width/Math.max(1,e.dimensions.height)});if(0===s.length)return{nodes:[]};const c=Te(s.map(e=>e.row)),u=Te(s.map(e=>e.column)),m=Math.max(1,Math.round(c[1]-c[0])+1),d=Math.max(1,Math.round(u[1]-u[0])+1),h=Math.max(0,t.layoutPadding??8),p=Math.max(1,e.dimensions.width-2*h)/d,f=Math.max(1,e.dimensions.height-2*h)/m,y=(e.dimensions.width-p*d)/2,g=(e.dimensions.height-f*m)/2,b=Oe(t.cellPadding??.12,0,.8),v=Math.max(1,.5*Math.min(p,f)*(1-b)),k=t.sizeAccessor?s.map(e=>Number($e(e.datum,t.sizeAccessor))):[],x=t.sizeDomain??Te(k),w=t.sizeRange??[.36,1],S=Oe(Math.min(w[0],w[1]),.05,1),M=Oe(Math.max(w[0],w[1]),S,1),A=s.map((o,i)=>{const n={...o.datum,gridRow:o.row,gridColumn:o.column},r=($e(n,t.idAccessor,["id","key","name"])??"grid-"+i)+"",a=($e(n,t.labelAccessor,["abbr","code","label","name","id"])??r)+"",l=Math.max(1,t.maxLabelLength??4),s=a.length>l?a.slice(0,l):a,m=$e(n,t.categoryAccessor),d=null==m?void 0:m+"",h=$e(n,t.fillAccessor),b=null!=h?h+"":d?e.resolveColor(d):e.theme.categorical[0]??"#4f86c6",k=t.sizeAccessor?Number($e(n,t.sizeAccessor)):NaN,w=t.sizeAccessor&&Number.isFinite(k)?Math.sqrt(Oe(Ee(k,x),0,1)):1,A=v*(S+w*(M-S)),C="function"==typeof t.markStyle?t.markStyle(n,i):t.markStyle;return{datum:n,id:r,label:s,category:d,row:o.row,column:o.column,x:y+(o.column-u[0]+.5)*p,y:g+(o.row-c[0]+.5)*f,radius:A,style:{fill:b,fillOpacity:.94,stroke:"rgba(255,255,255,0.9)",strokeWidth:1,...C}}}),C=t.shape??"circle";return{nodes:A.map(e=>{return"circle"===C?{type:"point",x:e.x,y:e.y,r:e.radius,style:e.style,datum:e.datum,accessibleDatum:e.datum,accessibility:{label:e.label,tableFields:{name:e.datum.name??e.label,label:e.label,row:e.row,column:e.column,...e.category?{category:e.category}:{}}},pointId:e.id,_transitionKey:e.id}:{type:"geoarea",pathData:"hexagon"===C?function(e,t,o){const i=[];for(let n=0;6>n;n+=1){const r=-Math.PI/2+n*(Math.PI/3);i.push([e+Math.cos(r)*o,t+Math.sin(r)*o])}return Ue(i)}(e.x,e.y,e.radius):Ue([[(t=e.x)-(i=e.radius),(o=e.y)-i],[t+i,o-i],[t+i,o+i],[t-i,o+i]]),centroid:[e.x,e.y],bounds:[[e.x-e.radius,e.y-e.radius],[e.x+e.radius,e.y+e.radius]],screenArea:"hexagon"===C?3*Math.sqrt(3)*e.radius*e.radius/2:(2*e.radius)**2,style:e.style,datum:e.datum,accessibleDatum:e.datum,accessibility:{label:e.label,tableFields:{name:e.datum.name??e.label,label:e.label,row:e.row,column:e.column,...e.category?{category:e.category}:{}}},group:e.category,interactive:!0};var t,o,i}),overlays:!1===t.showLabels?null:We(Ge,{marks:A,color:t.labelColor??"#ffffff",fontSize:t.labelFontSize??Oe(.23*Math.min(p,f),7,14),fontFamily:t.labelFontFamily,fontWeight:t.labelFontWeight??700}),restyle:(e,t)=>t?.isActive&&e.datum?{opacity:t.predicate(e.datum)?1:.18}:{opacity:1}}};function Ge({marks:e,color:t,fontSize:o,fontFamily:i,fontWeight:n}){const r=d();return We("g",{"aria-hidden":"true",pointerEvents:"none",children:e.map(e=>{const a=!r.isActive||r.predicate(e.datum);return We("text",{x:e.x,y:e.y,fill:t,fontFamily:i,fontSize:o,fontWeight:n,opacity:a?1:.18,textAnchor:"middle",dominantBaseline:"central",children:e.label},e.id)})})}import{geoBounds as qe,geoContains as Ke}from"d3-geo";import{jsx as _e}from"react/jsx-runtime";var Ye=new WeakMap,Xe=new WeakMap,Ve=new WeakMap,Je=1;function Qe(e,t,o){return Math.max(t,Math.min(o,e))}function et(e){if(Number.isFinite(e)&&Number(e)>0)return Number(e)}function tt(e,t){return"function"==typeof t?t(e,e.dotIndex):"string"==typeof t?e[t]:void 0}function ot(e){return e.properties&&"object"==typeof e.properties?{...e.properties}:{}}function it(e,t){const o=ot(e);return(e.id??o.id??o.name??"feature-"+t)+""}function nt(e,t,o,i){return[Math.ceil((e-o)/i-.5),Math.floor((t-o)/i-.5)]}function rt(e){if(!e)return 0;const t=Ve.get(e);if(t)return t;const o=Je;return Je+=1,Ve.set(e,o),o}function at(e,t){return!t||!(t[0][1]>e[1]||e[1]>t[1][1]||(o=e[0],i=t[0][0],n=t[1][0],i>n?i>o&&o>n:i>o||o>n));var o,i,n}function lt(e,t){for(const o of e){const{feature:e,index:i}=o;if(e.geometry&&at(t,o.bounds))try{if(Ke(e,t))return{feature:e,index:i}}catch{}}return null}function st(e,t,o,i={}){const n=e.filter((e,t)=>e.geometry&&(!i.featureFilter||i.featureFilter(e,t))),r=function(e,t){if(0===e.length)return null;const o=t.bounds({type:"FeatureCollection",features:e});return Number.isFinite(o[0][0])&&Number.isFinite(o[0][1])&&Number.isFinite(o[1][0])&&Number.isFinite(o[1][1])?o:null}(n,t.geoPath);if(!r)return{dots:[],cellSize:10,features:n};const a=Math.max(0,i.layoutPadding??0),l=[[Qe(r[0][0],a,Math.max(a,o.width-a)),Qe(r[0][1],a,Math.max(a,o.height-a))],[Qe(r[1][0],a,Math.max(a,o.width-a)),Qe(r[1][1],a,Math.max(a,o.height-a))]],s=Math.max(0,l[1][0]-l[0][0]),c=Math.max(0,l[1][1]-l[0][1]);if(0===s||0===c)return{dots:[],cellSize:10,features:n};const u=et(i.columns);let m=Math.max(2,u?s/u:et(i.cellSize)??10);const d=Math.max(100,Math.round(et(i.maxSamples)??25e3)),h=Math.ceil(s/m)*Math.ceil(c/m);h>d&&(m*=Math.sqrt(h/d));const p=i.gridOrigin?.[0]??0,f=i.gridOrigin?.[1]??0,[y,g]=nt(l[0][0],l[1][0],p,m),[b,v]=nt(l[0][1],l[1][1],f,m),k=[],x=function(e){return e.map((e,t)=>{if(Xe.has(e))return{feature:e,index:t,bounds:Xe.get(e)??null};try{const o=qe(e);return Xe.set(e,o),{feature:e,index:t,bounds:o}}catch{return Xe.set(e,null),{feature:e,index:t,bounds:null}}})}(n);for(let e=b;v>=e;e+=1){const o=f+(e+.5)*m;for(let n=y;g>=n;n+=1){const r=t.invertedPoint(p+(n+.5)*m,o);if(!r||!Number.isFinite(r[0])||!Number.isFinite(r[1]))continue;const a=lt(x,r);if(!a)continue;const l={...ot(a.feature),featureId:it(a.feature,a.index),featureIndex:a.index,gridRow:e,gridColumn:n,longitude:r[0],latitude:r[1],dotIndex:k.length};i.dotFilter&&!i.dotFilter(l,k.length)||k.push(l)}}return{dots:k,cellSize:m,features:n}}function ct(e){return Math.round(1e4*e)/1e4}function ut(e){return Array.isArray(e)&&e.length>=2&&Number.isFinite(e[0])&&Number.isFinite(e[1])?`${ct(Number(e[0]))},${ct(Number(e[1]))}`:"null"}function mt(e,t){const o=e[t];return"function"==typeof o?o.call(e):void 0}function dt(e){return"number"==typeof e&&Number.isFinite(e)?ct(e)+"":null===e?"null":"unavailable"}function ht(e){const t=e.scales.projection;return[dt(mt(t,"scale")),ut(mt(t,"translate")),ut(mt(t,"center")),(o=mt(t,"rotate"),Array.isArray(o)&&o.every(Number.isFinite)?o.map(e=>ct(Number(e))).join(","):"unavailable"),dt(mt(t,"clipAngle")),dt(mt(t,"precision")),...[[0,0],[-120,35],[45,45],[120,-30]].map(([t,o])=>ut(e.scales.projectedPoint(t,o)))].join("|");var o}function pt(e){return e.map(([e,t],o)=>`${0===o?"M":"L"}${e},${t}`).join("")+"Z"}var ft=e=>{const t=function(e){let t=Ye.get(e.areas);t||(t=new Map,Ye.set(e.areas,t));const o=function(e){const t=e.config;return[e.areas.length,e.dimensions.width,e.dimensions.height,t.cellSize??"",t.columns??"",t.layoutPadding??"",t.gridOrigin?.join(",")??"",t.maxSamples??"",rt(t.featureFilter),rt(t.dotFilter),ht(e)].join("::")}(e),i=t.get(o);if(i)return i;const n=st(e.areas,e.scales,e.dimensions,e.config);if(t.size>=12){const e=t.keys().next().value;void 0!==e&&t.delete(e)}return t.set(o,n),n}(e),o=e.config,i=o.shape??"circle",n=Math.max(.5,et(o.dotRadius)??t.cellSize*Qe(o.radiusRatio??.24,.05,.5)),r=o.gridOrigin?.[0]??0,a=o.gridOrigin?.[1]??0;return{nodes:t.dots.map((l,s)=>{const c=r+(l.gridColumn+.5)*t.cellSize,u=a+(l.gridRow+.5)*t.cellSize,m=tt(l,o.categoryAccessor),d=tt(l,o.fillAccessor),h={fill:null!=d?d+"":null!=m?e.resolveColor(m+""):e.theme.categorical[0]??"#4f86c6",fillOpacity:.92,strokeWidth:0,..."function"==typeof o.markStyle?o.markStyle(l,s):o.markStyle},p=`dot-${l.gridRow}-${l.gridColumn}`;if("circle"===i)return{type:"point",x:c,y:u,r:n,style:h,datum:l,interactive:!1,pointId:p,_transitionKey:p};const f="hexagon"===i?function(e,t,o){return pt(Array.from({length:6},(i,n)=>{const r=-Math.PI/2+n*(Math.PI/3);return[e+Math.cos(r)*o,t+Math.sin(r)*o]}))}(c,u,n):function(e,t,o){return pt([[e-o,t-o],[e+o,t-o],[e+o,t+o],[e-o,t+o]])}(c,u,n);return{type:"geoarea",pathData:f,centroid:[c,u],bounds:[[c-n,u-n],[c+n,u+n]],screenArea:"hexagon"===i?3*Math.sqrt(3)*n*n/2:(2*n)**2,style:h,datum:l,group:l.featureId,interactive:!1}}),overlays:o.showOutline?_e("g",{"aria-hidden":"true",pointerEvents:"none",children:t.features.map((t,i)=>{const n=e.scales.geoPath(t);return n?_e("path",{d:n,fill:"none",stroke:o.outlineStyle?.stroke??"currentColor",strokeOpacity:o.outlineStyle?.opacity??o.outlineStyle?.fillOpacity??.22,strokeWidth:o.outlineStyle?.strokeWidth??.7,strokeDasharray:o.outlineStyle?.strokeDasharray,strokeLinecap:o.outlineStyle?.strokeLinecap,vectorEffect:"non-scaling-stroke"},it(t,i)):null})}):null,restyle:(e,t)=>t?.isActive&&e.datum?{opacity:t.predicate(e.datum)?1:.14}:{opacity:1}}};function yt(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})}export{ae as ChoroplethMap,e as DEFAULT_HIT_RADIUS,Le as DistanceCartogram,Ae as FlowMap,n as GeoCustomChart,fe as ProportionalSymbolMap,r as StreamGeoFrame,h as composeStyleRules,t as geoAreaHitTarget,o as geoHitTarget,ft as geographicDotGridLayout,Ze as geographicGridLayout,B as glyphExtent,$ as glyphPlacement,Be as gridifyGeographicPoints,A as hatchFillId,C as hatchPatternDef,i as hitTargetPoint,R as isHatchFill,p as makeNodeRuleContext,f as makeRuleValueResolver,y as matchesThreshold,yt as mergeData,oe as resolveReferenceGeography,P as resolveResponsiveRules,g as resolveStyleRules,I as resolveSvgFill,H as responsiveRuleMatches,b as ruleMatches,st as sampleGeographicDotGrid};