@feltmaps/js-sdk 1.5.0-next.4 → 1.5.0-next.6

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.
package/dist/client.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var g=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var b=(e,n)=>{for(var r in n)g(e,r,{get:n[r],enumerable:!0})},I=(e,n,r,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let l of S(n))!M.call(e,l)&&l!==r&&g(e,l,{get:()=>n[l],enumerable:!(s=F(n,l))||s.enumerable});return e};var G=e=>I(g({},"__esModule",{value:!0}),e);var f={};b(f,{Felt:()=>V});module.exports=G(f);function o(e,n){return r=>{let s=new MessageChannel,l=r.handler,i="options"in r?r.options:void 0,a=crypto.randomUUID();return e.postMessage({type:"felt.addListener",event:i?{eventName:n,id:a,options:i}:{eventName:n,id:a}},"*",[s.port2]),s.port1.onmessage=d=>{l(d.data)},()=>{s.port1.onmessage=null,s.port1.close(),s.port2.close(),e.postMessage({type:"felt.removeListener",id:a},"*")}}}function t(e,n){return r=>{let s=new MessageChannel;return e.postMessage({type:n,params:r},"*",[s.port2]),new Promise((l,i)=>{s.port1.onmessage=a=>{a.data&&typeof a.data=="object"&&"__error__"in a.data?i(new Error(a.data.__error__)):l(a.data),s.port1.close(),s.port2.close()}})}}var u=e=>({getElement:t(e,"getElement"),getElementGeometry:t(e,"getElementGeometry"),getElements:t(e,"getElements"),setElementGroupVisibility:t(e,"setElementGroupVisibility"),getElementGroup:t(e,"getElementGroup"),getElementGroups:t(e,"getElementGroups"),onElementChange:o(e,"onElementChange"),onElementCreate:o(e,"onElementCreate"),onElementDelete:o(e,"onElementDelete"),onElementGroupChange:o(e,"onElementGroupChange"),createElement:t(e,"createElement"),updateElement:t(e,"updateElement"),deleteElement:t(e,"deleteElement")});var C=e=>({onPointerClick:o(e,"onPointerClick"),onPointerMove:o(e,"onPointerMove")});var h=e=>({getLayer:t(e,"getLayer"),getLayers:t(e,"getLayers"),setLayerVisibility:t(e,"setLayerVisibility"),setLayerStyle:t(e,"setLayerStyle"),setLayerLegendVisibility:t(e,"setLayerLegendVisibility"),onLayerChange:o(e,"onLayerChange"),getLayerGroup:t(e,"getLayerGroup"),getLayerGroups:t(e,"getLayerGroups"),setLayerGroupVisibility:t(e,"setLayerGroupVisibility"),setLayerGroupLegendVisibility:t(e,"setLayerGroupLegendVisibility"),onLayerGroupChange:o(e,"onLayerGroupChange"),getLegendItem:t(e,"getLegendItem"),getLegendItems:t(e,"getLegendItems"),setLegendItemVisibility:t(e,"setLegendItemVisibility"),onLegendItemChange:o(e,"onLegendItemChange"),getLayerFilters:t(e,"getLayerFilters"),setLayerFilters:t(e,"setLayerFilters"),getRenderedFeatures:t(e,"getRenderedFeatures")});var L=e=>({onSelectionChange:o(e,"onSelectionChange"),getSelection:t(e,"getSelection"),selectFeature:t(e,"selectFeature"),clearSelection:t(e,"clearSelection")});var T=e=>({setTool:t(e,"setTool"),getTool:t(e,"getTool"),onToolChange:o(e,"onToolChange"),setToolSettings:t(e,"setToolSettings"),getToolSettings:t(e,"getToolSettings"),onToolSettingsChange:o(e,"onToolSettingsChange")});var E=e=>({updateUiControls:t(e,"updateUiControls"),setOnMapInteractionsUi:t(e,"setOnMapInteractionsUi")});var v=e=>({getViewport:t(e,"getViewport"),setViewport:t(e,"setViewport"),getViewportConstraints:t(e,"getViewportConstraints"),setViewportConstraints:t(e,"setViewportConstraints"),fitViewportToBounds:t(e,"fitViewportToBounds"),onViewportMove:o(e,"onViewportMove"),onViewportMoveEnd:o(e,"onViewportMoveEnd"),onMapIdle:o(e,"onMapIdle")});function P(e){return{iframe:null,...v(e),...E(e),...h(e),...u(e),...L(e),...C(e),...T(e)}}var V={embed(e,n,r){let s={uiControls:{showLegend:!0,cooperativeGestures:!0,fullScreenButton:!0,geolocation:!1,zoomControls:!0,scaleBar:!0},initialViewport:void 0,origin:"https://felt.com"},l=r?.origin??s.origin,i=new URL(`${l}/embed/map/${n}`),a={showLegend:"legend",cooperativeGestures:"cooperativeGestures",fullScreenButton:"link",geolocation:"geolocation",zoomControls:"zoomControls",scaleBar:"scaleBar"},d={...s.uiControls,...r?.uiControls};for(let[m,y]of x(d))y!=null&&i.searchParams.set(a[m],y?"1":"0");if(r?.token&&i.searchParams.set("token",r.token),r?.initialViewport){let m=r.initialViewport;i.searchParams.set("loc",`${m.center.latitude},${m.center.longitude},${m.zoom}z`)}let c=e.tagName==="IFRAME",p=c?e:e.ownerDocument.createElement("iframe");return p.src=i.toString(),c||(p.style.width="100%",p.style.height="100%",p.style.border="none",p.style.margin="0",e.appendChild(p)),p.referrerPolicy="strict-origin-when-cross-origin",new Promise((m,y)=>{p.addEventListener("load",()=>{p.contentWindow==null?y(new Error("Failed to load Felt map")):m(p.contentWindow)},{once:!0})}).then(V.connect).then(m=>(Object.defineProperties(m,{iframe:{value:p,writable:!1,configurable:!1}}),m))},connect(e){let n=P(e);return new Promise((r,s)=>{let l=setTimeout(()=>{s(new Error("Failed to load Felt map")),clearInterval(a)},5e3),i=new MessageChannel,a=setInterval(()=>{e.postMessage({type:"felt.ready"},"*",[i.port2])},100);i.port1.onmessage=d=>{d.data===!0&&(clearInterval(a),clearTimeout(l),i.port1.close(),i.port2.close(),r(n))}})}},x=Object.entries;0&&(module.exports={Felt});
1
+ "use strict";var y=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var b=(e,n)=>{for(var r in n)y(e,r,{get:n[r],enumerable:!0})},x=(e,n,r,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let l of G(n))!S.call(e,l)&&l!==r&&y(e,l,{get:()=>n[l],enumerable:!(s=F(n,l))||s.enumerable});return e};var I=e=>x(y({},"__esModule",{value:!0}),e);var K={};b(K,{Felt:()=>M});module.exports=I(K);function o(e,n){return r=>{let s=new MessageChannel,l=r.handler,i="options"in r?r.options:void 0,a=crypto.randomUUID();return e.postMessage({type:"felt.addListener",event:i?{eventName:n,id:a,options:i}:{eventName:n,id:a}},"*",[s.port2]),s.port1.onmessage=d=>{l(d.data)},()=>{s.port1.onmessage=null,s.port1.close(),s.port2.close(),e.postMessage({type:"felt.removeListener",id:a},"*")}}}function t(e,n){return r=>{let s=new MessageChannel;return e.postMessage({type:n,params:r},"*",[s.port2]),new Promise((l,i)=>{s.port1.onmessage=a=>{a.data&&typeof a.data=="object"&&"__error__"in a.data?i(new Error(a.data.__error__)):l(a.data),s.port1.close(),s.port2.close()}})}}var u=e=>({getElement:t(e,"getElement"),getElementGeometry:t(e,"getElementGeometry"),getElements:t(e,"getElements"),setElementGroupVisibility:t(e,"setElementGroupVisibility"),getElementGroup:t(e,"getElementGroup"),getElementGroups:t(e,"getElementGroups"),onElementChange:o(e,"onElementChange"),onElementCreate:o(e,"onElementCreate"),onElementDelete:o(e,"onElementDelete"),onElementGroupChange:o(e,"onElementGroupChange"),createElement:t(e,"createElement"),updateElement:t(e,"updateElement"),deleteElement:t(e,"deleteElement")});var C=e=>({onPointerClick:o(e,"onPointerClick"),onPointerMove:o(e,"onPointerMove")});var h=e=>({getLayer:t(e,"getLayer"),getLayers:t(e,"getLayers"),setLayerVisibility:t(e,"setLayerVisibility"),setLayerStyle:t(e,"setLayerStyle"),setLayerLegendVisibility:t(e,"setLayerLegendVisibility"),onLayerChange:o(e,"onLayerChange"),getLayerGroup:t(e,"getLayerGroup"),getLayerGroups:t(e,"getLayerGroups"),setLayerGroupVisibility:t(e,"setLayerGroupVisibility"),setLayerGroupLegendVisibility:t(e,"setLayerGroupLegendVisibility"),onLayerGroupChange:o(e,"onLayerGroupChange"),getLegendItem:t(e,"getLegendItem"),getLegendItems:t(e,"getLegendItems"),setLegendItemVisibility:t(e,"setLegendItemVisibility"),onLegendItemChange:o(e,"onLegendItemChange"),getLayerFilters:t(e,"getLayerFilters"),setLayerFilters:t(e,"setLayerFilters"),getRenderedFeatures:t(e,"getRenderedFeatures"),getCategoryData:t(e,"getCategoryData"),getHistogramData:t(e,"getHistogramData"),getAggregates:t(e,"getAggregates")});var L=e=>({getMapDetails:t(e,"getMapDetails")});var T=e=>({onSelectionChange:o(e,"onSelectionChange"),getSelection:t(e,"getSelection"),selectFeature:t(e,"selectFeature"),clearSelection:t(e,"clearSelection")});var E=e=>({setTool:t(e,"setTool"),getTool:t(e,"getTool"),onToolChange:o(e,"onToolChange"),setToolSettings:t(e,"setToolSettings"),getToolSettings:t(e,"getToolSettings"),onToolSettingsChange:o(e,"onToolSettingsChange")});var v=e=>({updateUiControls:t(e,"updateUiControls"),setOnMapInteractionsUi:t(e,"setOnMapInteractionsUi")});var P=e=>({getViewport:t(e,"getViewport"),setViewport:t(e,"setViewport"),getViewportConstraints:t(e,"getViewportConstraints"),setViewportConstraints:t(e,"setViewportConstraints"),fitViewportToBounds:t(e,"fitViewportToBounds"),onViewportMove:o(e,"onViewportMove"),onViewportMoveEnd:o(e,"onViewportMoveEnd"),onMapIdle:o(e,"onMapIdle")});function V(e){return{iframe:null,...P(e),...v(e),...h(e),...u(e),...T(e),...C(e),...E(e),...L(e)}}var M={embed(e,n,r){let s={uiControls:{showLegend:!0,cooperativeGestures:!0,fullScreenButton:!0,geolocation:!1,zoomControls:!0,scaleBar:!0},initialViewport:void 0,origin:"https://felt.com"},l=r?.origin??s.origin,i=new URL(`${l}/embed/map/${n}`),a={showLegend:"legend",cooperativeGestures:"cooperativeGestures",fullScreenButton:"link",geolocation:"geolocation",zoomControls:"zoomControls",scaleBar:"scaleBar"},d={...s.uiControls,...r?.uiControls};for(let[p,g]of f(d))g!=null&&i.searchParams.set(a[p],g?"1":"0");if(r?.token&&i.searchParams.set("token",r.token),r?.initialViewport){let p=r.initialViewport;i.searchParams.set("loc",`${p.center.latitude},${p.center.longitude},${p.zoom}z`)}let c=e.tagName==="IFRAME",m=c?e:e.ownerDocument.createElement("iframe");return m.src=i.toString(),c||(m.style.width="100%",m.style.height="100%",m.style.border="none",m.style.margin="0",e.appendChild(m)),m.referrerPolicy="strict-origin-when-cross-origin",new Promise((p,g)=>{m.addEventListener("load",()=>{m.contentWindow==null?g(new Error("Failed to load Felt map")):p(m.contentWindow)},{once:!0})}).then(M.connect).then(p=>(Object.defineProperties(p,{iframe:{value:m,writable:!1,configurable:!1}}),p))},connect(e){let n=V(e);return new Promise((r,s)=>{let l=setTimeout(()=>{s(new Error("Failed to load Felt map")),clearInterval(a)},5e3),i=new MessageChannel,a=setInterval(()=>{e.postMessage({type:"felt.ready"},"*",[i.port2])},100);i.port1.onmessage=d=>{d.data===!0&&(clearInterval(a),clearTimeout(l),i.port1.close(),i.port2.close(),r(n))}})}},f=Object.entries;0&&(module.exports={Felt});
package/dist/client.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { E as Element, G as Geometry, a as GetElementsConstraint, b as ElementGroup, c as GetElementGroupsConstraint, S as SetVisibilityRequest, d as ElementChangeCallbackParams, e as ElementGroupChangeCallbackParams, f as ElementCreate, g as ElementUpdate, L as Layer, h as GetLayersConstraint, i as LayerChangeCallbackParams, j as LayerGroup, k as GetLayerGroupsConstraint, l as LayerGroupChangeCallbackParams, m as LegendItemIdentifier, n as LegendItem, o as LegendItemsConstraint, p as LegendItemChangeCallbackParams, q as LayerFilters, F as Filters, r as GetRenderedFeaturesConstraint, s as Feature, M as MapInteractionEvent, t as EntityNode, u as FeatureSelection, T as ToolType, I as InputToolSettings, C as ConfigurableToolType, v as ToolSettingsMap, w as ToolSettingsChangeEvent, z as zInfer, V as ViewportState, x as SetViewportCenterZoomParams, y as ViewportConstraints, A as ViewportFitBoundsParams, B as ViewportCenterZoom } from './types-CPZlLnbg.cjs';
2
- export { D as CircleElementCreate, H as CircleElementRead, J as CircleElementUpdate, av as CircleToolSettings, ah as ElementGroupNode, ai as ElementNode, aj as FeatureNode, am as FeltBoundary, an as FeltZoom, ae as FilterExpression, af as FilterLogicGate, ag as FilterTernary, K as HighlighterElementCreate, N as HighlighterElementRead, O as HighlighterElementUpdate, aw as HighlighterToolSettings, P as ImageElementCreate, Q as ImageElementRead, R as ImageElementUpdate, ao as LatLng, ak as LayerGroupNode, al as LayerNode, ac as LayerProcessingStatus, ap as LineStringGeometry, ax as LineToolSettings, U as LinkElementRead, aq as LngLatTuple, W as MarkerElementCreate, X as MarkerElementRead, Y as MarkerElementUpdate, ay as MarkerToolSettings, ar as MultiLineStringGeometry, as as MultiPolygonGeometry, Z as NoteElementCreate, _ as NoteElementRead, $ as NoteElementUpdate, az as NoteToolSettings, a0 as PathElementCreate, a1 as PathElementRead, a2 as PathElementUpdate, aA as PinToolSettings, a3 as PlaceElementCreate, a4 as PlaceElementRead, a5 as PlaceElementUpdate, aB as PlaceFrame, aC as PlaceSymbol, at as PointGeometry, a6 as PolygonElementCreate, a7 as PolygonElementRead, a8 as PolygonElementUpdate, au as PolygonGeometry, aD as PolygonToolSettings, ad as RasterValue, aE as RouteToolSettings, a9 as TextElementCreate, aa as TextElementRead, ab as TextElementUpdate, aF as TextToolSettings } from './types-CPZlLnbg.cjs';
1
+ import { E as Element, G as Geometry, a as GetElementsConstraint, b as ElementGroup, c as GetElementGroupsConstraint, S as SetVisibilityRequest, d as ElementChangeCallbackParams, e as ElementGroupChangeCallbackParams, f as ElementCreate, g as ElementUpdate, L as Layer, h as GetLayersConstraint, i as LayerChangeCallbackParams, j as LayerGroup, k as GetLayerGroupsConstraint, l as LayerGroupChangeCallbackParams, m as LegendItemIdentifier, n as LegendItem, o as LegendItemsConstraint, p as LegendItemChangeCallbackParams, q as LayerFilters, F as Filters, r as GetRenderedFeaturesConstraint, s as Feature, t as GetLayerCategoriesParams, u as GetLayerCategoriesGroup, v as GetLayerHistogramParams, w as GetLayerHistogramBin, A as AggregationMethod, x as GetLayerCalculationParams, M as MapInteractionEvent, y as MapDetails, z as EntityNode, B as FeatureSelection, T as ToolType, I as InputToolSettings, C as ConfigurableToolType, D as ToolSettingsMap, H as ToolSettingsChangeEvent, J as zInfer, V as ViewportState, K as SetViewportCenterZoomParams, N as ViewportConstraints, O as ViewportFitBoundsParams, P as ViewportCenterZoom } from './types-CQwkpLq-.cjs';
2
+ export { ao as AggregationConfig, Q as CircleElementCreate, R as CircleElementRead, U as CircleElementUpdate, aF as CircleToolSettings, ar as ElementGroupNode, as as ElementNode, at as FeatureNode, aw as FeltBoundary, ax as FeltZoom, al as FilterExpression, am as FilterLogicGate, an as FilterTernary, W as HighlighterElementCreate, X as HighlighterElementRead, Y as HighlighterElementUpdate, aG as HighlighterToolSettings, Z as ImageElementCreate, _ as ImageElementRead, $ as ImageElementUpdate, ay as LatLng, au as LayerGroupNode, av as LayerNode, aj as LayerProcessingStatus, az as LineStringGeometry, aH as LineToolSettings, a0 as LinkElementRead, aA as LngLatTuple, a1 as MarkerElementCreate, a2 as MarkerElementRead, a3 as MarkerElementUpdate, aI as MarkerToolSettings, ap as MultiAggregationConfig, aB as MultiLineStringGeometry, aC as MultiPolygonGeometry, a4 as NoteElementCreate, a5 as NoteElementRead, a6 as NoteElementUpdate, aJ as NoteToolSettings, a7 as PathElementCreate, a8 as PathElementRead, a9 as PathElementUpdate, aK as PinToolSettings, aa as PlaceElementCreate, ab as PlaceElementRead, ac as PlaceElementUpdate, aL as PlaceFrame, aM as PlaceSymbol, aD as PointGeometry, ad as PolygonElementCreate, ae as PolygonElementRead, af as PolygonElementUpdate, aE as PolygonGeometry, aN as PolygonToolSettings, ak as RasterValue, aO as RouteToolSettings, ag as TextElementCreate, ah as TextElementRead, ai as TextElementUpdate, aP as TextToolSettings, aq as ValueConfiguration } from './types-CQwkpLq-.cjs';
3
3
  import { z } from 'zod';
4
4
 
5
5
  /**
@@ -537,6 +537,157 @@ interface LayersController {
537
537
  * The constraints to apply to the features returned from the map.
538
538
  */
539
539
  params?: GetRenderedFeaturesConstraint): Promise<Array<Feature>>;
540
+ /**
541
+ * Gets values from a layer grouped by a given attribute.
542
+ *
543
+ * @remarks
544
+ * Groups features in your layer by unique values in the specified attribute and calculates
545
+ * a value for each group. By default, this value is the count of features in each group.
546
+ *
547
+ * You can apply filters in two ways:
548
+ * 1. At the top level (using `boundary` and `filters`), which affects both what categories
549
+ * are included and how values are calculated
550
+ * 2. In the `values` configuration, which only affects the values but keeps all categories
551
+ *
552
+ * This two-level filtering is particularly useful when you want to compare subsets of data
553
+ * while maintaining consistent categories. For example, you might want to show the distribution
554
+ * of all building types in a city, but only count buildings built after 2000 in each category.
555
+ *
556
+ * @example
557
+ * ```typescript
558
+ * // Basic grouping: Count of buildings by type
559
+ * const buildingsByType = await felt.getCategoryData({
560
+ * layerId: "buildings",
561
+ * attribute: "type"
562
+ * });
563
+ *
564
+ * // Filtered grouping: Only count buildings in downtown
565
+ * const downtownBuildingsByType = await felt.getCategoryData({
566
+ * layerId: "buildings",
567
+ * attribute: "type",
568
+ * boundary: [-122.43, 47.60, -122.33, 47.62] // downtown boundary
569
+ * });
570
+ *
571
+ * // Advanced: Show all building types, but only sum floor area of recent buildings
572
+ * const recentBuildingAreaByType = await felt.getCategoryData({
573
+ * layerId: "buildings",
574
+ * attribute: "type",
575
+ * values: {
576
+ * filters: ["year_built", "gte", 2000],
577
+ * aggregation: {
578
+ * method: "sum",
579
+ * attribute: "floor_area"
580
+ * }
581
+ * }
582
+ * });
583
+ *
584
+ * // Compare residential density across neighborhoods while only counting recent buildings
585
+ * const newBuildingDensityByNeighborhood = await felt.getCategoryData({
586
+ * layerId: "buildings",
587
+ * attribute: "neighborhood",
588
+ * values: {
589
+ * filters: ["year_built", "gte", 2000],
590
+ * aggregation: {
591
+ * method: "avg",
592
+ * attribute: "units_per_acre"
593
+ * }
594
+ * }
595
+ * });
596
+ * ```
597
+ */
598
+ getCategoryData(params: GetLayerCategoriesParams): Promise<Array<GetLayerCategoriesGroup>>;
599
+ /**
600
+ * Gets a histogram of values from a layer for a given attribute.
601
+ *
602
+ * @remarks
603
+ * Creates bins (ranges) for numeric data and counts how many features fall into each bin,
604
+ * or returns aggregated values for each bin.
605
+ *
606
+ * You can control how the bins are created using the `steps` parameter, choosing from
607
+ * several methods like equal intervals, quantiles, or natural breaks (Jenks), or passing
608
+ * in the step values directly if you know how you want to bin the data.
609
+ *
610
+ * Like getCategoryData, you can apply filters in two ways:
611
+ * 1. At the top level (using `boundary` and `filters`), which affects both how the bins
612
+ * are calculated and what features are counted in each bin
613
+ * 2. In the `values` configuration, which only affects what gets counted but keeps the
614
+ * bin ranges the same
615
+ *
616
+ * This is particularly useful when you want to compare distributions while keeping
617
+ * consistent bin ranges. For example, you might want to compare the distribution of
618
+ * building heights in different years while using the same height ranges.
619
+ *
620
+ * @example
621
+ * ```typescript
622
+ * // Basic histogram: Building heights in 5 natural break bins
623
+ * const buildingHeights = await felt.getHistogramData({
624
+ * layerId: "buildings",
625
+ * attribute: "height",
626
+ * steps: { type: "jenks", count: 5 }
627
+ * });
628
+ *
629
+ * // Compare old vs new buildings using the same height ranges
630
+ * const oldBuildingHeights = await felt.getHistogramData({
631
+ * layerId: "buildings",
632
+ * attribute: "height",
633
+ * steps: [0, 20, 50, 100, 200, 500],
634
+ * values: {
635
+ * filters: ["year_built", "lt", 1950]
636
+ * }
637
+ * });
638
+ *
639
+ * const newBuildingHeights = await felt.getHistogramData({
640
+ * layerId: "buildings",
641
+ * attribute: "height",
642
+ * steps: [0, 20, 50, 100, 200, 500], // Same ranges as above
643
+ * values: {
644
+ * filters: ["year_built", "gte", 1950]
645
+ * }
646
+ * });
647
+ * ```
648
+ */
649
+ getHistogramData(params: GetLayerHistogramParams): Promise<Array<GetLayerHistogramBin>>;
650
+ /**
651
+ * Calculates a single aggregate value for a layer based on the provided configuration.
652
+ *
653
+ * @remarks
654
+ * Performs statistical calculations on your data, like counting features or computing
655
+ * averages, sums, etc. You can focus your calculation on specific areas or subsets
656
+ * of your data using boundaries and filters.
657
+ *
658
+ * When no aggregation is specified, it counts features. When an aggregation is provided,
659
+ * it performs that calculation (average, sum, etc.) on the specified attribute.
660
+ *
661
+ * @example
662
+ * ```typescript
663
+ * // Count all residential buildings
664
+ * const residentialCount = await felt.getAggregates({
665
+ * layerId: "buildings",
666
+ * filters: ["type", "eq", "residential"]
667
+ * });
668
+ *
669
+ * // Calculate average home value in a specific neighborhood
670
+ * const avgHomeValue = await felt.getAggregates({
671
+ * layerId: "buildings",
672
+ * boundary: [-122.43, 47.60, -122.33, 47.62], // neighborhood boundary
673
+ * aggregation: {
674
+ * method: "avg",
675
+ * attribute: "assessed_value"
676
+ * }
677
+ * });
678
+ *
679
+ * // Find the maximum building height for buildings built after 2000
680
+ * const maxNewBuildingHeight = await felt.getAggregates({
681
+ * layerId: "buildings",
682
+ * filters: ["year_built", "gte", 2000],
683
+ * aggregation: {
684
+ * method: "max",
685
+ * attribute: "height"
686
+ * }
687
+ * });
688
+ * ```
689
+ */
690
+ getAggregates<T extends AggregationMethod | "count">(params: GetLayerCalculationParams<T>): Promise<Record<T, number | null>>;
540
691
  }
541
692
 
542
693
  /**
@@ -593,6 +744,17 @@ interface InteractionsController {
593
744
  }): VoidFunction;
594
745
  }
595
746
 
747
+ /**
748
+ * @group Controller
749
+ * @public
750
+ */
751
+ interface MiscController {
752
+ /**
753
+ * Gets the details of the map.
754
+ */
755
+ getMapDetails(): Promise<MapDetails>;
756
+ }
757
+
596
758
  /**
597
759
  * The Selection controller allows you to listen for changes to the selection on the map.
598
760
  *
@@ -1095,7 +1257,7 @@ interface ViewportController {
1095
1257
  * @group Controller
1096
1258
  * @public
1097
1259
  */
1098
- interface FeltController extends ViewportController, UiController, LayersController, ElementsController, SelectionController, InteractionsController, ToolsController {
1260
+ interface FeltController extends ViewportController, UiController, LayersController, ElementsController, SelectionController, InteractionsController, ToolsController, InteractionsController, MiscController {
1099
1261
  /**
1100
1262
  * The iframe element containing the Felt map, if it is an embedded map.
1101
1263
  *
@@ -1266,4 +1428,4 @@ declare const Felt: {
1266
1428
  connect(feltWindow: Window): Promise<FeltController>;
1267
1429
  };
1268
1430
 
1269
- export { ConfigurableToolType, Element, ElementChangeCallbackParams, ElementCreate, ElementGroup, ElementGroupChangeCallbackParams, ElementUpdate, type ElementsController, EntityNode, Feature, FeatureSelection, Felt, type FeltController, type FeltEmbedOptions, Filters, Geometry, GetElementGroupsConstraint, GetElementsConstraint, GetLayerGroupsConstraint, GetLayersConstraint, GetRenderedFeaturesConstraint, InputToolSettings, type InteractionsController, Layer, LayerChangeCallbackParams, LayerFilters, LayerGroup, LayerGroupChangeCallbackParams, type LayersController, LegendItem, LegendItemChangeCallbackParams, LegendItemIdentifier, LegendItemsConstraint, MapInteractionEvent, type UiOnMapInteractionsOptions as OnMapInteractionsOptions, type SelectionController, SetViewportCenterZoomParams, SetVisibilityRequest, ToolSettingsChangeEvent, ToolSettingsMap, ToolType, type ToolsController, type UiController, type UiControlsOptions, ViewportCenterZoom, ViewportConstraints, type ViewportController, ViewportFitBoundsParams, ViewportState };
1431
+ export { AggregationMethod, ConfigurableToolType, Element, ElementChangeCallbackParams, ElementCreate, ElementGroup, ElementGroupChangeCallbackParams, ElementUpdate, type ElementsController, EntityNode, Feature, FeatureSelection, Felt, type FeltController, type FeltEmbedOptions, Filters, Geometry, GetElementGroupsConstraint, GetElementsConstraint, GetLayerCalculationParams, GetLayerCategoriesGroup, GetLayerCategoriesParams, GetLayerGroupsConstraint, GetLayerHistogramBin, GetLayerHistogramParams, GetLayersConstraint, GetRenderedFeaturesConstraint, InputToolSettings, type InteractionsController, Layer, LayerChangeCallbackParams, LayerFilters, LayerGroup, LayerGroupChangeCallbackParams, type LayersController, LegendItem, LegendItemChangeCallbackParams, LegendItemIdentifier, LegendItemsConstraint, MapDetails, MapInteractionEvent, type MiscController, type UiOnMapInteractionsOptions as OnMapInteractionsOptions, type SelectionController, SetViewportCenterZoomParams, SetVisibilityRequest, ToolSettingsChangeEvent, ToolSettingsMap, ToolType, type ToolsController, type UiController, type UiControlsOptions, ViewportCenterZoom, ViewportConstraints, type ViewportController, ViewportFitBoundsParams, ViewportState };
package/dist/client.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { E as Element, G as Geometry, a as GetElementsConstraint, b as ElementGroup, c as GetElementGroupsConstraint, S as SetVisibilityRequest, d as ElementChangeCallbackParams, e as ElementGroupChangeCallbackParams, f as ElementCreate, g as ElementUpdate, L as Layer, h as GetLayersConstraint, i as LayerChangeCallbackParams, j as LayerGroup, k as GetLayerGroupsConstraint, l as LayerGroupChangeCallbackParams, m as LegendItemIdentifier, n as LegendItem, o as LegendItemsConstraint, p as LegendItemChangeCallbackParams, q as LayerFilters, F as Filters, r as GetRenderedFeaturesConstraint, s as Feature, M as MapInteractionEvent, t as EntityNode, u as FeatureSelection, T as ToolType, I as InputToolSettings, C as ConfigurableToolType, v as ToolSettingsMap, w as ToolSettingsChangeEvent, z as zInfer, V as ViewportState, x as SetViewportCenterZoomParams, y as ViewportConstraints, A as ViewportFitBoundsParams, B as ViewportCenterZoom } from './types-CPZlLnbg.js';
2
- export { D as CircleElementCreate, H as CircleElementRead, J as CircleElementUpdate, av as CircleToolSettings, ah as ElementGroupNode, ai as ElementNode, aj as FeatureNode, am as FeltBoundary, an as FeltZoom, ae as FilterExpression, af as FilterLogicGate, ag as FilterTernary, K as HighlighterElementCreate, N as HighlighterElementRead, O as HighlighterElementUpdate, aw as HighlighterToolSettings, P as ImageElementCreate, Q as ImageElementRead, R as ImageElementUpdate, ao as LatLng, ak as LayerGroupNode, al as LayerNode, ac as LayerProcessingStatus, ap as LineStringGeometry, ax as LineToolSettings, U as LinkElementRead, aq as LngLatTuple, W as MarkerElementCreate, X as MarkerElementRead, Y as MarkerElementUpdate, ay as MarkerToolSettings, ar as MultiLineStringGeometry, as as MultiPolygonGeometry, Z as NoteElementCreate, _ as NoteElementRead, $ as NoteElementUpdate, az as NoteToolSettings, a0 as PathElementCreate, a1 as PathElementRead, a2 as PathElementUpdate, aA as PinToolSettings, a3 as PlaceElementCreate, a4 as PlaceElementRead, a5 as PlaceElementUpdate, aB as PlaceFrame, aC as PlaceSymbol, at as PointGeometry, a6 as PolygonElementCreate, a7 as PolygonElementRead, a8 as PolygonElementUpdate, au as PolygonGeometry, aD as PolygonToolSettings, ad as RasterValue, aE as RouteToolSettings, a9 as TextElementCreate, aa as TextElementRead, ab as TextElementUpdate, aF as TextToolSettings } from './types-CPZlLnbg.js';
1
+ import { E as Element, G as Geometry, a as GetElementsConstraint, b as ElementGroup, c as GetElementGroupsConstraint, S as SetVisibilityRequest, d as ElementChangeCallbackParams, e as ElementGroupChangeCallbackParams, f as ElementCreate, g as ElementUpdate, L as Layer, h as GetLayersConstraint, i as LayerChangeCallbackParams, j as LayerGroup, k as GetLayerGroupsConstraint, l as LayerGroupChangeCallbackParams, m as LegendItemIdentifier, n as LegendItem, o as LegendItemsConstraint, p as LegendItemChangeCallbackParams, q as LayerFilters, F as Filters, r as GetRenderedFeaturesConstraint, s as Feature, t as GetLayerCategoriesParams, u as GetLayerCategoriesGroup, v as GetLayerHistogramParams, w as GetLayerHistogramBin, A as AggregationMethod, x as GetLayerCalculationParams, M as MapInteractionEvent, y as MapDetails, z as EntityNode, B as FeatureSelection, T as ToolType, I as InputToolSettings, C as ConfigurableToolType, D as ToolSettingsMap, H as ToolSettingsChangeEvent, J as zInfer, V as ViewportState, K as SetViewportCenterZoomParams, N as ViewportConstraints, O as ViewportFitBoundsParams, P as ViewportCenterZoom } from './types-CQwkpLq-.js';
2
+ export { ao as AggregationConfig, Q as CircleElementCreate, R as CircleElementRead, U as CircleElementUpdate, aF as CircleToolSettings, ar as ElementGroupNode, as as ElementNode, at as FeatureNode, aw as FeltBoundary, ax as FeltZoom, al as FilterExpression, am as FilterLogicGate, an as FilterTernary, W as HighlighterElementCreate, X as HighlighterElementRead, Y as HighlighterElementUpdate, aG as HighlighterToolSettings, Z as ImageElementCreate, _ as ImageElementRead, $ as ImageElementUpdate, ay as LatLng, au as LayerGroupNode, av as LayerNode, aj as LayerProcessingStatus, az as LineStringGeometry, aH as LineToolSettings, a0 as LinkElementRead, aA as LngLatTuple, a1 as MarkerElementCreate, a2 as MarkerElementRead, a3 as MarkerElementUpdate, aI as MarkerToolSettings, ap as MultiAggregationConfig, aB as MultiLineStringGeometry, aC as MultiPolygonGeometry, a4 as NoteElementCreate, a5 as NoteElementRead, a6 as NoteElementUpdate, aJ as NoteToolSettings, a7 as PathElementCreate, a8 as PathElementRead, a9 as PathElementUpdate, aK as PinToolSettings, aa as PlaceElementCreate, ab as PlaceElementRead, ac as PlaceElementUpdate, aL as PlaceFrame, aM as PlaceSymbol, aD as PointGeometry, ad as PolygonElementCreate, ae as PolygonElementRead, af as PolygonElementUpdate, aE as PolygonGeometry, aN as PolygonToolSettings, ak as RasterValue, aO as RouteToolSettings, ag as TextElementCreate, ah as TextElementRead, ai as TextElementUpdate, aP as TextToolSettings, aq as ValueConfiguration } from './types-CQwkpLq-.js';
3
3
  import { z } from 'zod';
4
4
 
5
5
  /**
@@ -537,6 +537,157 @@ interface LayersController {
537
537
  * The constraints to apply to the features returned from the map.
538
538
  */
539
539
  params?: GetRenderedFeaturesConstraint): Promise<Array<Feature>>;
540
+ /**
541
+ * Gets values from a layer grouped by a given attribute.
542
+ *
543
+ * @remarks
544
+ * Groups features in your layer by unique values in the specified attribute and calculates
545
+ * a value for each group. By default, this value is the count of features in each group.
546
+ *
547
+ * You can apply filters in two ways:
548
+ * 1. At the top level (using `boundary` and `filters`), which affects both what categories
549
+ * are included and how values are calculated
550
+ * 2. In the `values` configuration, which only affects the values but keeps all categories
551
+ *
552
+ * This two-level filtering is particularly useful when you want to compare subsets of data
553
+ * while maintaining consistent categories. For example, you might want to show the distribution
554
+ * of all building types in a city, but only count buildings built after 2000 in each category.
555
+ *
556
+ * @example
557
+ * ```typescript
558
+ * // Basic grouping: Count of buildings by type
559
+ * const buildingsByType = await felt.getCategoryData({
560
+ * layerId: "buildings",
561
+ * attribute: "type"
562
+ * });
563
+ *
564
+ * // Filtered grouping: Only count buildings in downtown
565
+ * const downtownBuildingsByType = await felt.getCategoryData({
566
+ * layerId: "buildings",
567
+ * attribute: "type",
568
+ * boundary: [-122.43, 47.60, -122.33, 47.62] // downtown boundary
569
+ * });
570
+ *
571
+ * // Advanced: Show all building types, but only sum floor area of recent buildings
572
+ * const recentBuildingAreaByType = await felt.getCategoryData({
573
+ * layerId: "buildings",
574
+ * attribute: "type",
575
+ * values: {
576
+ * filters: ["year_built", "gte", 2000],
577
+ * aggregation: {
578
+ * method: "sum",
579
+ * attribute: "floor_area"
580
+ * }
581
+ * }
582
+ * });
583
+ *
584
+ * // Compare residential density across neighborhoods while only counting recent buildings
585
+ * const newBuildingDensityByNeighborhood = await felt.getCategoryData({
586
+ * layerId: "buildings",
587
+ * attribute: "neighborhood",
588
+ * values: {
589
+ * filters: ["year_built", "gte", 2000],
590
+ * aggregation: {
591
+ * method: "avg",
592
+ * attribute: "units_per_acre"
593
+ * }
594
+ * }
595
+ * });
596
+ * ```
597
+ */
598
+ getCategoryData(params: GetLayerCategoriesParams): Promise<Array<GetLayerCategoriesGroup>>;
599
+ /**
600
+ * Gets a histogram of values from a layer for a given attribute.
601
+ *
602
+ * @remarks
603
+ * Creates bins (ranges) for numeric data and counts how many features fall into each bin,
604
+ * or returns aggregated values for each bin.
605
+ *
606
+ * You can control how the bins are created using the `steps` parameter, choosing from
607
+ * several methods like equal intervals, quantiles, or natural breaks (Jenks), or passing
608
+ * in the step values directly if you know how you want to bin the data.
609
+ *
610
+ * Like getCategoryData, you can apply filters in two ways:
611
+ * 1. At the top level (using `boundary` and `filters`), which affects both how the bins
612
+ * are calculated and what features are counted in each bin
613
+ * 2. In the `values` configuration, which only affects what gets counted but keeps the
614
+ * bin ranges the same
615
+ *
616
+ * This is particularly useful when you want to compare distributions while keeping
617
+ * consistent bin ranges. For example, you might want to compare the distribution of
618
+ * building heights in different years while using the same height ranges.
619
+ *
620
+ * @example
621
+ * ```typescript
622
+ * // Basic histogram: Building heights in 5 natural break bins
623
+ * const buildingHeights = await felt.getHistogramData({
624
+ * layerId: "buildings",
625
+ * attribute: "height",
626
+ * steps: { type: "jenks", count: 5 }
627
+ * });
628
+ *
629
+ * // Compare old vs new buildings using the same height ranges
630
+ * const oldBuildingHeights = await felt.getHistogramData({
631
+ * layerId: "buildings",
632
+ * attribute: "height",
633
+ * steps: [0, 20, 50, 100, 200, 500],
634
+ * values: {
635
+ * filters: ["year_built", "lt", 1950]
636
+ * }
637
+ * });
638
+ *
639
+ * const newBuildingHeights = await felt.getHistogramData({
640
+ * layerId: "buildings",
641
+ * attribute: "height",
642
+ * steps: [0, 20, 50, 100, 200, 500], // Same ranges as above
643
+ * values: {
644
+ * filters: ["year_built", "gte", 1950]
645
+ * }
646
+ * });
647
+ * ```
648
+ */
649
+ getHistogramData(params: GetLayerHistogramParams): Promise<Array<GetLayerHistogramBin>>;
650
+ /**
651
+ * Calculates a single aggregate value for a layer based on the provided configuration.
652
+ *
653
+ * @remarks
654
+ * Performs statistical calculations on your data, like counting features or computing
655
+ * averages, sums, etc. You can focus your calculation on specific areas or subsets
656
+ * of your data using boundaries and filters.
657
+ *
658
+ * When no aggregation is specified, it counts features. When an aggregation is provided,
659
+ * it performs that calculation (average, sum, etc.) on the specified attribute.
660
+ *
661
+ * @example
662
+ * ```typescript
663
+ * // Count all residential buildings
664
+ * const residentialCount = await felt.getAggregates({
665
+ * layerId: "buildings",
666
+ * filters: ["type", "eq", "residential"]
667
+ * });
668
+ *
669
+ * // Calculate average home value in a specific neighborhood
670
+ * const avgHomeValue = await felt.getAggregates({
671
+ * layerId: "buildings",
672
+ * boundary: [-122.43, 47.60, -122.33, 47.62], // neighborhood boundary
673
+ * aggregation: {
674
+ * method: "avg",
675
+ * attribute: "assessed_value"
676
+ * }
677
+ * });
678
+ *
679
+ * // Find the maximum building height for buildings built after 2000
680
+ * const maxNewBuildingHeight = await felt.getAggregates({
681
+ * layerId: "buildings",
682
+ * filters: ["year_built", "gte", 2000],
683
+ * aggregation: {
684
+ * method: "max",
685
+ * attribute: "height"
686
+ * }
687
+ * });
688
+ * ```
689
+ */
690
+ getAggregates<T extends AggregationMethod | "count">(params: GetLayerCalculationParams<T>): Promise<Record<T, number | null>>;
540
691
  }
541
692
 
542
693
  /**
@@ -593,6 +744,17 @@ interface InteractionsController {
593
744
  }): VoidFunction;
594
745
  }
595
746
 
747
+ /**
748
+ * @group Controller
749
+ * @public
750
+ */
751
+ interface MiscController {
752
+ /**
753
+ * Gets the details of the map.
754
+ */
755
+ getMapDetails(): Promise<MapDetails>;
756
+ }
757
+
596
758
  /**
597
759
  * The Selection controller allows you to listen for changes to the selection on the map.
598
760
  *
@@ -1095,7 +1257,7 @@ interface ViewportController {
1095
1257
  * @group Controller
1096
1258
  * @public
1097
1259
  */
1098
- interface FeltController extends ViewportController, UiController, LayersController, ElementsController, SelectionController, InteractionsController, ToolsController {
1260
+ interface FeltController extends ViewportController, UiController, LayersController, ElementsController, SelectionController, InteractionsController, ToolsController, InteractionsController, MiscController {
1099
1261
  /**
1100
1262
  * The iframe element containing the Felt map, if it is an embedded map.
1101
1263
  *
@@ -1266,4 +1428,4 @@ declare const Felt: {
1266
1428
  connect(feltWindow: Window): Promise<FeltController>;
1267
1429
  };
1268
1430
 
1269
- export { ConfigurableToolType, Element, ElementChangeCallbackParams, ElementCreate, ElementGroup, ElementGroupChangeCallbackParams, ElementUpdate, type ElementsController, EntityNode, Feature, FeatureSelection, Felt, type FeltController, type FeltEmbedOptions, Filters, Geometry, GetElementGroupsConstraint, GetElementsConstraint, GetLayerGroupsConstraint, GetLayersConstraint, GetRenderedFeaturesConstraint, InputToolSettings, type InteractionsController, Layer, LayerChangeCallbackParams, LayerFilters, LayerGroup, LayerGroupChangeCallbackParams, type LayersController, LegendItem, LegendItemChangeCallbackParams, LegendItemIdentifier, LegendItemsConstraint, MapInteractionEvent, type UiOnMapInteractionsOptions as OnMapInteractionsOptions, type SelectionController, SetViewportCenterZoomParams, SetVisibilityRequest, ToolSettingsChangeEvent, ToolSettingsMap, ToolType, type ToolsController, type UiController, type UiControlsOptions, ViewportCenterZoom, ViewportConstraints, type ViewportController, ViewportFitBoundsParams, ViewportState };
1431
+ export { AggregationMethod, ConfigurableToolType, Element, ElementChangeCallbackParams, ElementCreate, ElementGroup, ElementGroupChangeCallbackParams, ElementUpdate, type ElementsController, EntityNode, Feature, FeatureSelection, Felt, type FeltController, type FeltEmbedOptions, Filters, Geometry, GetElementGroupsConstraint, GetElementsConstraint, GetLayerCalculationParams, GetLayerCategoriesGroup, GetLayerCategoriesParams, GetLayerGroupsConstraint, GetLayerHistogramBin, GetLayerHistogramParams, GetLayersConstraint, GetRenderedFeaturesConstraint, InputToolSettings, type InteractionsController, Layer, LayerChangeCallbackParams, LayerFilters, LayerGroup, LayerGroupChangeCallbackParams, type LayersController, LegendItem, LegendItemChangeCallbackParams, LegendItemIdentifier, LegendItemsConstraint, MapDetails, MapInteractionEvent, type MiscController, type UiOnMapInteractionsOptions as OnMapInteractionsOptions, type SelectionController, SetViewportCenterZoomParams, SetVisibilityRequest, ToolSettingsChangeEvent, ToolSettingsMap, ToolType, type ToolsController, type UiController, type UiControlsOptions, ViewportCenterZoom, ViewportConstraints, type ViewportController, ViewportFitBoundsParams, ViewportState };
package/dist/client.js CHANGED
@@ -1 +1 @@
1
- function o(e,p){return n=>{let r=new MessageChannel,m=n.handler,s="options"in n?n.options:void 0,i=crypto.randomUUID();return e.postMessage({type:"felt.addListener",event:s?{eventName:p,id:i,options:s}:{eventName:p,id:i}},"*",[r.port2]),r.port1.onmessage=d=>{m(d.data)},()=>{r.port1.onmessage=null,r.port1.close(),r.port2.close(),e.postMessage({type:"felt.removeListener",id:i},"*")}}}function t(e,p){return n=>{let r=new MessageChannel;return e.postMessage({type:p,params:n},"*",[r.port2]),new Promise((m,s)=>{r.port1.onmessage=i=>{i.data&&typeof i.data=="object"&&"__error__"in i.data?s(new Error(i.data.__error__)):m(i.data),r.port1.close(),r.port2.close()}})}}var c=e=>({getElement:t(e,"getElement"),getElementGeometry:t(e,"getElementGeometry"),getElements:t(e,"getElements"),setElementGroupVisibility:t(e,"setElementGroupVisibility"),getElementGroup:t(e,"getElementGroup"),getElementGroups:t(e,"getElementGroups"),onElementChange:o(e,"onElementChange"),onElementCreate:o(e,"onElementCreate"),onElementDelete:o(e,"onElementDelete"),onElementGroupChange:o(e,"onElementGroupChange"),createElement:t(e,"createElement"),updateElement:t(e,"updateElement"),deleteElement:t(e,"deleteElement")});var u=e=>({onPointerClick:o(e,"onPointerClick"),onPointerMove:o(e,"onPointerMove")});var C=e=>({getLayer:t(e,"getLayer"),getLayers:t(e,"getLayers"),setLayerVisibility:t(e,"setLayerVisibility"),setLayerStyle:t(e,"setLayerStyle"),setLayerLegendVisibility:t(e,"setLayerLegendVisibility"),onLayerChange:o(e,"onLayerChange"),getLayerGroup:t(e,"getLayerGroup"),getLayerGroups:t(e,"getLayerGroups"),setLayerGroupVisibility:t(e,"setLayerGroupVisibility"),setLayerGroupLegendVisibility:t(e,"setLayerGroupLegendVisibility"),onLayerGroupChange:o(e,"onLayerGroupChange"),getLegendItem:t(e,"getLegendItem"),getLegendItems:t(e,"getLegendItems"),setLegendItemVisibility:t(e,"setLegendItemVisibility"),onLegendItemChange:o(e,"onLegendItemChange"),getLayerFilters:t(e,"getLayerFilters"),setLayerFilters:t(e,"setLayerFilters"),getRenderedFeatures:t(e,"getRenderedFeatures")});var h=e=>({onSelectionChange:o(e,"onSelectionChange"),getSelection:t(e,"getSelection"),selectFeature:t(e,"selectFeature"),clearSelection:t(e,"clearSelection")});var L=e=>({setTool:t(e,"setTool"),getTool:t(e,"getTool"),onToolChange:o(e,"onToolChange"),setToolSettings:t(e,"setToolSettings"),getToolSettings:t(e,"getToolSettings"),onToolSettingsChange:o(e,"onToolSettingsChange")});var T=e=>({updateUiControls:t(e,"updateUiControls"),setOnMapInteractionsUi:t(e,"setOnMapInteractionsUi")});var E=e=>({getViewport:t(e,"getViewport"),setViewport:t(e,"setViewport"),getViewportConstraints:t(e,"getViewportConstraints"),setViewportConstraints:t(e,"setViewportConstraints"),fitViewportToBounds:t(e,"fitViewportToBounds"),onViewportMove:o(e,"onViewportMove"),onViewportMoveEnd:o(e,"onViewportMoveEnd"),onMapIdle:o(e,"onMapIdle")});function v(e){return{iframe:null,...E(e),...T(e),...C(e),...c(e),...h(e),...u(e),...L(e)}}var P={embed(e,p,n){let r={uiControls:{showLegend:!0,cooperativeGestures:!0,fullScreenButton:!0,geolocation:!1,zoomControls:!0,scaleBar:!0},initialViewport:void 0,origin:"https://felt.com"},m=n?.origin??r.origin,s=new URL(`${m}/embed/map/${p}`),i={showLegend:"legend",cooperativeGestures:"cooperativeGestures",fullScreenButton:"link",geolocation:"geolocation",zoomControls:"zoomControls",scaleBar:"scaleBar"},d={...r.uiControls,...n?.uiControls};for(let[l,y]of V(d))y!=null&&s.searchParams.set(i[l],y?"1":"0");if(n?.token&&s.searchParams.set("token",n.token),n?.initialViewport){let l=n.initialViewport;s.searchParams.set("loc",`${l.center.latitude},${l.center.longitude},${l.zoom}z`)}let g=e.tagName==="IFRAME",a=g?e:e.ownerDocument.createElement("iframe");return a.src=s.toString(),g||(a.style.width="100%",a.style.height="100%",a.style.border="none",a.style.margin="0",e.appendChild(a)),a.referrerPolicy="strict-origin-when-cross-origin",new Promise((l,y)=>{a.addEventListener("load",()=>{a.contentWindow==null?y(new Error("Failed to load Felt map")):l(a.contentWindow)},{once:!0})}).then(P.connect).then(l=>(Object.defineProperties(l,{iframe:{value:a,writable:!1,configurable:!1}}),l))},connect(e){let p=v(e);return new Promise((n,r)=>{let m=setTimeout(()=>{r(new Error("Failed to load Felt map")),clearInterval(i)},5e3),s=new MessageChannel,i=setInterval(()=>{e.postMessage({type:"felt.ready"},"*",[s.port2])},100);s.port1.onmessage=d=>{d.data===!0&&(clearInterval(i),clearTimeout(m),s.port1.close(),s.port2.close(),n(p))}})}},V=Object.entries;export{P as Felt};
1
+ function o(e,m){return n=>{let r=new MessageChannel,p=n.handler,s="options"in n?n.options:void 0,i=crypto.randomUUID();return e.postMessage({type:"felt.addListener",event:s?{eventName:m,id:i,options:s}:{eventName:m,id:i}},"*",[r.port2]),r.port1.onmessage=d=>{p(d.data)},()=>{r.port1.onmessage=null,r.port1.close(),r.port2.close(),e.postMessage({type:"felt.removeListener",id:i},"*")}}}function t(e,m){return n=>{let r=new MessageChannel;return e.postMessage({type:m,params:n},"*",[r.port2]),new Promise((p,s)=>{r.port1.onmessage=i=>{i.data&&typeof i.data=="object"&&"__error__"in i.data?s(new Error(i.data.__error__)):p(i.data),r.port1.close(),r.port2.close()}})}}var c=e=>({getElement:t(e,"getElement"),getElementGeometry:t(e,"getElementGeometry"),getElements:t(e,"getElements"),setElementGroupVisibility:t(e,"setElementGroupVisibility"),getElementGroup:t(e,"getElementGroup"),getElementGroups:t(e,"getElementGroups"),onElementChange:o(e,"onElementChange"),onElementCreate:o(e,"onElementCreate"),onElementDelete:o(e,"onElementDelete"),onElementGroupChange:o(e,"onElementGroupChange"),createElement:t(e,"createElement"),updateElement:t(e,"updateElement"),deleteElement:t(e,"deleteElement")});var u=e=>({onPointerClick:o(e,"onPointerClick"),onPointerMove:o(e,"onPointerMove")});var C=e=>({getLayer:t(e,"getLayer"),getLayers:t(e,"getLayers"),setLayerVisibility:t(e,"setLayerVisibility"),setLayerStyle:t(e,"setLayerStyle"),setLayerLegendVisibility:t(e,"setLayerLegendVisibility"),onLayerChange:o(e,"onLayerChange"),getLayerGroup:t(e,"getLayerGroup"),getLayerGroups:t(e,"getLayerGroups"),setLayerGroupVisibility:t(e,"setLayerGroupVisibility"),setLayerGroupLegendVisibility:t(e,"setLayerGroupLegendVisibility"),onLayerGroupChange:o(e,"onLayerGroupChange"),getLegendItem:t(e,"getLegendItem"),getLegendItems:t(e,"getLegendItems"),setLegendItemVisibility:t(e,"setLegendItemVisibility"),onLegendItemChange:o(e,"onLegendItemChange"),getLayerFilters:t(e,"getLayerFilters"),setLayerFilters:t(e,"setLayerFilters"),getRenderedFeatures:t(e,"getRenderedFeatures"),getCategoryData:t(e,"getCategoryData"),getHistogramData:t(e,"getHistogramData"),getAggregates:t(e,"getAggregates")});var h=e=>({getMapDetails:t(e,"getMapDetails")});var L=e=>({onSelectionChange:o(e,"onSelectionChange"),getSelection:t(e,"getSelection"),selectFeature:t(e,"selectFeature"),clearSelection:t(e,"clearSelection")});var T=e=>({setTool:t(e,"setTool"),getTool:t(e,"getTool"),onToolChange:o(e,"onToolChange"),setToolSettings:t(e,"setToolSettings"),getToolSettings:t(e,"getToolSettings"),onToolSettingsChange:o(e,"onToolSettingsChange")});var E=e=>({updateUiControls:t(e,"updateUiControls"),setOnMapInteractionsUi:t(e,"setOnMapInteractionsUi")});var v=e=>({getViewport:t(e,"getViewport"),setViewport:t(e,"setViewport"),getViewportConstraints:t(e,"getViewportConstraints"),setViewportConstraints:t(e,"setViewportConstraints"),fitViewportToBounds:t(e,"fitViewportToBounds"),onViewportMove:o(e,"onViewportMove"),onViewportMoveEnd:o(e,"onViewportMoveEnd"),onMapIdle:o(e,"onMapIdle")});function P(e){return{iframe:null,...v(e),...E(e),...C(e),...c(e),...L(e),...u(e),...T(e),...h(e)}}var V={embed(e,m,n){let r={uiControls:{showLegend:!0,cooperativeGestures:!0,fullScreenButton:!0,geolocation:!1,zoomControls:!0,scaleBar:!0},initialViewport:void 0,origin:"https://felt.com"},p=n?.origin??r.origin,s=new URL(`${p}/embed/map/${m}`),i={showLegend:"legend",cooperativeGestures:"cooperativeGestures",fullScreenButton:"link",geolocation:"geolocation",zoomControls:"zoomControls",scaleBar:"scaleBar"},d={...r.uiControls,...n?.uiControls};for(let[l,g]of M(d))g!=null&&s.searchParams.set(i[l],g?"1":"0");if(n?.token&&s.searchParams.set("token",n.token),n?.initialViewport){let l=n.initialViewport;s.searchParams.set("loc",`${l.center.latitude},${l.center.longitude},${l.zoom}z`)}let y=e.tagName==="IFRAME",a=y?e:e.ownerDocument.createElement("iframe");return a.src=s.toString(),y||(a.style.width="100%",a.style.height="100%",a.style.border="none",a.style.margin="0",e.appendChild(a)),a.referrerPolicy="strict-origin-when-cross-origin",new Promise((l,g)=>{a.addEventListener("load",()=>{a.contentWindow==null?g(new Error("Failed to load Felt map")):l(a.contentWindow)},{once:!0})}).then(V.connect).then(l=>(Object.defineProperties(l,{iframe:{value:a,writable:!1,configurable:!1}}),l))},connect(e){let m=P(e);return new Promise((n,r)=>{let p=setTimeout(()=>{r(new Error("Failed to load Felt map")),clearInterval(i)},5e3),s=new MessageChannel,i=setInterval(()=>{e.postMessage({type:"felt.ready"},"*",[s.port2])},100);s.port1.onmessage=d=>{d.data===!0&&(clearInterval(i),clearTimeout(p),s.port1.close(),s.port2.close(),n(m))}})}},M=Object.entries;export{V as Felt};
package/dist/handler.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var Z=Object.defineProperty;var De=Object.getOwnPropertyDescriptor;var We=Object.getOwnPropertyNames;var Ke=Object.prototype.hasOwnProperty;var _e=(o,i)=>{for(var I in i)Z(o,I,{get:i[I],enumerable:!0})},Qe=(o,i,I,T)=>{if(i&&typeof i=="object"||typeof i=="function")for(let b of We(i))!Ke.call(o,b)&&b!==I&&Z(o,b,{get:()=>i[b],enumerable:!(T=De(i,b))||T.enumerable});return o};var $e=o=>Qe(Z({},"__esModule",{value:!0}),o);var ko={};_e(ko,{createMessageHandler:()=>Co});module.exports=$e(ko);var c=require("zod");var y=require("zod");var h=require("zod");function t(o,i){return h.z.strictObject({type:h.z.literal(o),params:i})}function L(o,i){return h.z.strictObject({eventName:h.z.literal(o),id:h.z.string(),options:i})}function l(o){return h.z.strictObject({eventName:h.z.literal(o),id:h.z.string()})}var r=require("zod"),V=r.z.number(),v=r.z.number(),O=r.z.object({latitude:v,longitude:V}),P=r.z.tuple([V,v]),me=r.z.object({type:r.z.literal("Point"),coordinates:P}),Je=r.z.object({type:r.z.literal("LineString"),coordinates:r.z.array(P)}),C=r.z.object({type:r.z.literal("MultiLineString"),coordinates:r.z.array(Je.shape.coordinates)}),ce=r.z.number().min(1).max(23),k=r.z.tuple([V,v,V,v]),E=r.z.object({show:r.z.array(r.z.string()).optional(),hide:r.z.array(r.z.string()).optional()});var e=require("zod");var g=e.z.object({id:e.z.string(),groupId:e.z.string().nullable(),color:e.z.string(),name:e.z.union([e.z.string(),e.z.null()]),description:e.z.union([e.z.string(),e.z.null()]),attributes:e.z.record(e.z.string(),e.z.unknown())}),U=e.z.object({imageUrl:e.z.string().nullable()}),B=e.z.object({strokeOpacity:e.z.number(),strokeWidth:e.z.number(),strokeStyle:e.z.enum(["solid","dashed","dotted"])}),Xe=e.z.enum(["meter","kilometer","foot","mile"]),H=g.extend(U.shape).extend({type:e.z.literal("Place"),coordinates:me.shape.coordinates,symbol:e.z.string(),frame:e.z.enum(["frame-circle","frame-square"]).nullable(),hideLabel:e.z.boolean()}),A=g.extend(U.shape).extend(B.shape).extend({type:e.z.literal("Path"),coordinates:C.shape.coordinates,distanceMarker:e.z.boolean(),endCaps:e.z.boolean(),routingMode:e.z.enum(["driving","cycling","walking","flying"]).nullable()}),D=g.extend(U.shape).extend(B.shape).extend({type:e.z.literal("Polygon"),coordinates:C.shape.coordinates,fillOpacity:e.z.number().min(0).max(1),areaMarker:e.z.boolean()}),W=g.extend(U.shape).extend(B.shape).extend({type:e.z.literal("Circle"),coordinates:P,radius:e.z.number(),radiusDisplayAngle:e.z.number(),radiusDisplayUnit:Xe.nullable(),fillOpacity:e.z.number().min(0).max(1),radiusMarker:e.z.boolean()}),K=g.extend({type:e.z.literal("Marker"),coordinates:C.shape.coordinates,opacity:e.z.number().min(0).max(1),size:e.z.number().min(0).max(100),zoom:e.z.number().min(0).max(23)}),_=g.extend({type:e.z.literal("Highlighter"),coordinates:C.shape.coordinates,opacity:e.z.number().min(0).max(1)}),de=e.z.object({position:P,rotation:e.z.number(),scale:e.z.number(),zoom:e.z.number().min(0).max(23),coordinates:C.shape.coordinates}),ye=e.z.object({text:e.z.string(),align:e.z.enum(["left","center","right"]),style:e.z.enum(["italic","light","regular","caps"]),name:e.z.string()}),Q=g.extend(de.shape).extend(ye.shape).extend({type:e.z.literal("Text")}),$=g.extend(de.shape).extend(ye.shape).extend({type:e.z.literal("Note"),widthScale:e.z.number().min(0)}),J=g.extend({type:e.z.literal("Image"),coordinates:C.shape.coordinates,imageUrl:e.z.string(),opacity:e.z.number().min(0).max(1)}).omit({color:!0}),Ye=g.extend({type:e.z.literal("Link"),coordinates:C.shape.coordinates,url:e.z.string()}),f={type:!0,coordinates:!0},S={id:!0},X=H.partial().required(f).omit(S),R=A.partial().required(f).omit(S),Y=D.partial().required(f).omit(S),ee=W.partial().required(f).required({radius:!0}).omit(S),te=K.partial().required(f).omit(S),oe=_.partial().required(f).omit(S),ne=Q.partial().required(f).required({text:!0}).omit(S).omit({coordinates:!0,name:!0}),re=$.partial().required(f).required({text:!0}).omit(S).omit({coordinates:!0,name:!0}),et=J.partial().required(f).required({imageUrl:!0}).omit(S),ge=e.z.discriminatedUnion("type",[X,R,Y,ee,te,oe,et,ne,re]),Uo=H.omit({coordinates:!0}),Ro=A.omit({coordinates:!0}),No=D.omit({coordinates:!0}),jo=W.omit({coordinates:!0}),qo=K.omit({coordinates:!0}),Zo=_.omit({coordinates:!0}),Bo=Q.omit({coordinates:!0}),Ho=$.omit({coordinates:!0}),Ao=J.omit({coordinates:!0}),Do=Ye.omit({coordinates:!0}),x={type:!0,id:!0},tt=H.partial().required(x),ot=A.partial().required(x),nt=D.partial().required(x),rt=W.partial().required(x),at=K.partial().required(x),it=_.partial().required(x),st=Q.partial().required(x).omit({coordinates:!0,name:!0}),lt=$.partial().required(x).omit({coordinates:!0,name:!0}),pt=J.partial().required(x),ue=e.z.discriminatedUnion("type",[tt,ot,nt,rt,at,it,st,lt,pt]),he=e.z.object({ids:e.z.array(e.z.string()).optional()}),fe=e.z.object({ids:e.z.array(e.z.string()).optional()});var mt=t("getElement",y.z.string()),ct=t("getElementGeometry",y.z.string()),dt=t("getElements",he.optional()),yt=t("getElementGroup",y.z.string()),gt=t("getElementGroups",fe.optional()),ut=t("setElementGroupVisibility",E),ht=L("onElementChange",y.z.object({id:y.z.string()})),ft=l("onElementCreate"),St=L("onElementDelete",y.z.object({id:y.z.string()})),xt=L("onElementGroupChange",y.z.object({id:y.z.string()})),Mt=t("createElement",ge),bt=t("updateElement",ue),Lt=t("deleteElement",y.z.string()),Se={methods:[mt,ct,dt,yt,gt,ut,Mt,bt,Lt],listeners:[ht,ft,St,xt]};var Ct=l("onPointerClick"),It=l("onPointerMove"),xe={methods:null,listeners:[Ct,It]};var s=require("zod");var n=require("zod"),Et=n.z.enum(["in","ni"]),Tt=n.z.enum(["lt","gt","le","ge","eq","ne","cn","nc","is","isnt"]),Yo=n.z.enum(["and","or"]),Me=n.z.union([n.z.number(),n.z.string(),n.z.boolean(),n.z.null()]),be=n.z.string().or(n.z.null()),Gt=n.z.tuple([be,Et,n.z.array(Me).or(n.z.null())]),zt=n.z.tuple([be,Tt,Me]),ae=n.z.union([Gt,zt]),ie=n.z.tuple([n.z.lazy(()=>n.z.union([ie,ae,n.z.null(),n.z.boolean()])),n.z.enum(["and","or"]),n.z.lazy(()=>n.z.union([ie,ae,n.z.null(),n.z.boolean()]))]),Le=n.z.union([ie,ae,n.z.null(),n.z.boolean()]);var a=require("zod");var on=a.z.enum(["processing","completed","failed","incomplete"]),Ce=a.z.object({ids:a.z.array(a.z.string()).optional()}),Ie=a.z.object({ids:a.z.array(a.z.string()).optional()}),G=a.z.object({id:a.z.string(),layerId:a.z.string()}),Ee=a.z.object({ids:G.array().optional(),layerIds:a.z.string().array().optional()}),Te=a.z.object({layerIds:a.z.array(a.z.string()).optional(),areaQuery:a.z.union([a.z.object({coordinates:O}),a.z.object({boundary:k})]).optional()});var Pt=t("getLayer",s.z.string()),kt=t("getLayers",Ce.optional()),Ft=t("setLayerVisibility",E),wt=L("onLayerChange",s.z.object({id:s.z.string()})),Vt=t("setLayerStyle",s.z.object({id:s.z.string(),style:s.z.object({}).passthrough()})),vt=t("setLayerLegendVisibility",E),Ot=t("getLayerGroup",s.z.string()),Ut=t("getLayerGroups",Ie.optional()),Rt=t("setLayerGroupVisibility",E),Nt=t("setLayerGroupLegendVisibility",E),jt=L("onLayerGroupChange",s.z.object({id:s.z.string()})),qt=t("getLegendItem",G),Zt=t("getLegendItems",Ee.optional()),Bt=L("onLegendItemChange",G),Ht=t("setLegendItemVisibility",s.z.object({show:G.array().optional(),hide:G.array().optional()})),At=t("getLayerFilters",s.z.string()),Dt=t("setLayerFilters",s.z.object({layerId:s.z.string(),filters:Le,note:s.z.string().optional()})),Wt=t("getRenderedFeatures",Te.optional()),Ge={methods:[Pt,kt,Ft,Vt,vt,Ot,Ut,Rt,Nt,qt,Zt,Ht,At,Dt,Wt],listeners:[wt,jt,Bt]};var F=require("zod");var M=require("zod"),ze=M.z.object({id:M.z.string().or(M.z.number()),layerId:M.z.string(),showPopup:M.z.boolean().optional(),fitViewport:M.z.boolean().or(M.z.object({maxZoom:M.z.number()})).optional()});var Kt=t("getSelection",F.z.undefined()),_t=l("onSelectionChange"),Qt=t("selectFeature",ze),$t=t("clearSelection",F.z.object({features:F.z.boolean().optional(),elements:F.z.boolean().optional()}).optional()),Pe={methods:[Kt,Qt,$t],listeners:[_t]};var ve=require("zod");var p=require("zod");var ke=["pin","line","route","polygon","circle","marker","highlighter","text","note"],Fe=p.z.enum([...ke,"link"]),we=p.z.enum(ke),Jt=X.pick({color:!0,symbol:!0,frame:!0}).required(),Xt=R.pick({color:!0,strokeOpacity:!0,strokeWidth:!0,strokeStyle:!0,distanceMarker:!0}).required(),Yt=R.pick({color:!0,routingMode:!0,strokeOpacity:!0,strokeWidth:!0,strokeStyle:!0,distanceMarker:!0,endCaps:!0}).required(),eo=Y.pick({color:!0,fillOpacity:!0,strokeOpacity:!0,strokeWidth:!0,strokeStyle:!0,areaMarker:!0}).required(),to=ee.pick({color:!0,fillOpacity:!0,strokeOpacity:!0,strokeWidth:!0,strokeStyle:!0,radiusMarker:!0}).required(),oo=te.pick({color:!0,opacity:!0,size:!0}).required(),no=oe.pick({color:!0,opacity:!0}).extend({size:p.z.number().min(0).max(200)}).required(),ro=ne.pick({color:!0,align:!0,style:!0}).required(),ao=re.pick({color:!0,align:!0,style:!0}).required(),Ve=p.z.discriminatedUnion("tool",[Jt.partial().extend({tool:p.z.literal("pin")}),Xt.partial().extend({tool:p.z.literal("line")}),Yt.partial().extend({tool:p.z.literal("route")}),eo.partial().extend({tool:p.z.literal("polygon")}),to.partial().extend({tool:p.z.literal("circle")}),oo.partial().extend({tool:p.z.literal("marker")}),no.partial().extend({tool:p.z.literal("highlighter")}),ro.partial().extend({tool:p.z.literal("text")}),ao.partial().extend({tool:p.z.literal("note")})]);var io=t("setTool",Fe.nullable()),so=t("getTool",ve.z.undefined()),lo=l("onToolChange"),po=t("setToolSettings",Ve),mo=t("getToolSettings",we),co=l("onToolSettingsChange"),Oe={methods:[io,so,po,mo],listeners:[lo,co]};var m=require("zod"),Ue=m.z.object({showLegend:m.z.boolean().optional(),cooperativeGestures:m.z.boolean().optional(),fullScreenButton:m.z.boolean().optional(),geolocation:m.z.boolean().optional(),zoomControls:m.z.boolean().optional(),scaleBar:m.z.boolean().optional()}),Re=m.z.object({featureSelectPanel:m.z.boolean().optional(),featureHoverPanel:m.z.boolean().optional(),elementSelectPanel:m.z.boolean().optional(),linkClickOpen:m.z.boolean().optional(),imageLightboxOpen:m.z.boolean().optional()});var yo=t("updateUiControls",Ue),go=t("setOnMapInteractionsUi",Re),Ne={methods:[yo,go],listeners:null};var se=require("zod");var w=require("zod");var N=w.z.object({center:O,zoom:ce}),je=w.z.object({center:N.shape.center.optional(),zoom:N.shape.zoom.optional()}),qe=w.z.object({minZoom:N.shape.zoom.nullish(),maxZoom:N.shape.zoom.nullish(),bounds:k.nullish()}).nullable(),Ze=w.z.object({bounds:k});var uo=t("getViewport",se.z.undefined()),ho=t("setViewport",je),fo=t("getViewportConstraints",se.z.undefined()),So=t("setViewportConstraints",qe),xo=t("fitViewportToBounds",Ze),Mo=l("onViewportMove"),bo=l("onViewportMoveEnd"),Lo=l("onMapIdle"),Be={methods:[ho,uo,fo,So,xo],listeners:[Mo,bo,Lo]};var le=[Ne,Be,Ge,Se,Pe,xe,Oe];function Co(o,i,I){let T=new Map;async function b(u){if(!Po.safeParse(u.data).success){I?.onUnknownMessage?.(u.data);return}let pe=Ae.safeParse(u.data);if(!pe.success){I?.onInvalidMessage?.(u.data);return}let{data:d}=pe;if(d.type==="felt.ready")u.ports[0]?.postMessage(!0);else if(d.type==="felt.addListener"){if(d.event.eventName==="")throw new Error("felt.addListener eventName cannot be empty");let z="options"in d.event?{options:"options"in d.event?d.event.options:void 0,handler:q=>{u.ports[0]?.postMessage(q)}}:{handler:q=>{u.ports[0]?.postMessage(q)}},j=i.listeners[d.event.eventName](z);T.set(d.event.id,j)}else if(d.type==="felt.removeListener")T.get(d.id)?.(),T.delete(d.id);else try{let z=i.methods[d.type],j=await z(d.params);u.ports[0]?.postMessage(j)}catch(z){u.ports[0]?.postMessage({__error__:Io(z)})}}return o.addEventListener("message",b),()=>{o.removeEventListener("message",b)}}function Io(o){return o instanceof Error?o.message:typeof o=="object"&&o!==null&&"message"in o?String(o.message):typeof o=="string"?o:"Unknown error"}var He={methods:le.map(o=>o.methods??[]).flat(),listeners:le.map(o=>o.listeners??[]).flat()},Eo=c.z.discriminatedUnion("eventName",[c.z.strictObject({eventName:c.z.literal("")}),...He.listeners]),To=c.z.strictObject({type:c.z.literal("felt.addListener"),event:Eo}),Go=c.z.strictObject({type:c.z.literal("felt.removeListener"),id:c.z.string()}),zo=c.z.strictObject({type:c.z.literal("felt.ready")}),Ae=c.z.discriminatedUnion("type",[zo,To,Go,...He.methods]),Po=c.z.object({type:c.z.enum(Ae.options.map(o=>o.shape.type.value))});0&&(module.exports={createMessageHandler});
1
+ "use strict";var Z=Object.defineProperty;var tt=Object.getOwnPropertyDescriptor;var ot=Object.getOwnPropertyNames;var rt=Object.prototype.hasOwnProperty;var nt=(r,s)=>{for(var E in s)Z(r,E,{get:s[E],enumerable:!0})},at=(r,s,E,F)=>{if(s&&typeof s=="object"||typeof s=="function")for(let L of ot(s))!rt.call(r,L)&&L!==E&&Z(r,L,{get:()=>s[L],enumerable:!(F=tt(s,L))||F.enumerable});return r};var it=r=>at(Z({},"__esModule",{value:!0}),r);var _o={};nt(_o,{createMessageHandler:()=>Ao});module.exports=it(_o);var g=require("zod");var y=require("zod");var f=require("zod");function t(r,s){return f.z.strictObject({type:f.z.literal(r),params:s})}function C(r,s){return f.z.strictObject({eventName:f.z.literal(r),id:f.z.string(),options:s})}function p(r){return f.z.strictObject({eventName:f.z.literal(r),id:f.z.string()})}var a=require("zod"),O=a.z.number(),U=a.z.number(),R=a.z.object({latitude:U,longitude:O}),I=a.z.tuple([O,U]),de=a.z.object({type:a.z.literal("Point"),coordinates:I}),ye=a.z.object({type:a.z.literal("Polygon"),coordinates:a.z.array(a.z.array(I))}),st=a.z.object({type:a.z.literal("LineString"),coordinates:a.z.array(I)}),G=a.z.object({type:a.z.literal("MultiLineString"),coordinates:a.z.array(st.shape.coordinates)}),ue=a.z.number().min(1).max(23),T=a.z.tuple([O,U,O,U]),z=a.z.object({show:a.z.array(a.z.string()).optional(),hide:a.z.array(a.z.string()).optional()});var e=require("zod");var u=e.z.object({id:e.z.string(),groupId:e.z.string().nullable(),color:e.z.string(),name:e.z.union([e.z.string(),e.z.null()]),description:e.z.union([e.z.string(),e.z.null()]),attributes:e.z.record(e.z.string(),e.z.unknown())}),N=e.z.object({imageUrl:e.z.string().nullable()}),D=e.z.object({strokeOpacity:e.z.number(),strokeWidth:e.z.number(),strokeStyle:e.z.enum(["solid","dashed","dotted"])}),lt=e.z.enum(["meter","kilometer","foot","mile"]),W=u.extend(N.shape).extend({type:e.z.literal("Place"),coordinates:de.shape.coordinates,symbol:e.z.string(),frame:e.z.enum(["frame-circle","frame-square"]).nullable(),hideLabel:e.z.boolean()}),K=u.extend(N.shape).extend(D.shape).extend({type:e.z.literal("Path"),coordinates:G.shape.coordinates,distanceMarker:e.z.boolean(),endCaps:e.z.boolean(),routingMode:e.z.enum(["driving","cycling","walking","flying"]).nullable()}),_=u.extend(N.shape).extend(D.shape).extend({type:e.z.literal("Polygon"),coordinates:G.shape.coordinates,fillOpacity:e.z.number().min(0).max(1),areaMarker:e.z.boolean()}),Q=u.extend(N.shape).extend(D.shape).extend({type:e.z.literal("Circle"),coordinates:I,radius:e.z.number(),radiusDisplayAngle:e.z.number(),radiusDisplayUnit:lt.nullable(),fillOpacity:e.z.number().min(0).max(1),radiusMarker:e.z.boolean()}),$=u.extend({type:e.z.literal("Marker"),coordinates:G.shape.coordinates,opacity:e.z.number().min(0).max(1),size:e.z.number().min(0).max(100),zoom:e.z.number().min(0).max(23)}),J=u.extend({type:e.z.literal("Highlighter"),coordinates:G.shape.coordinates,opacity:e.z.number().min(0).max(1)}),he=e.z.object({position:I,rotation:e.z.number(),scale:e.z.number(),zoom:e.z.number().min(0).max(23),coordinates:G.shape.coordinates}),fe=e.z.object({text:e.z.string(),align:e.z.enum(["left","center","right"]),style:e.z.enum(["italic","light","regular","caps"]),name:e.z.string()}),X=u.extend(he.shape).extend(fe.shape).extend({type:e.z.literal("Text")}),Y=u.extend(he.shape).extend(fe.shape).extend({type:e.z.literal("Note"),widthScale:e.z.number().min(0)}),ee=u.extend({type:e.z.literal("Image"),coordinates:G.shape.coordinates,imageUrl:e.z.string(),opacity:e.z.number().min(0).max(1)}).omit({color:!0}),pt=u.extend({type:e.z.literal("Link"),coordinates:G.shape.coordinates,url:e.z.string()}),S={type:!0,coordinates:!0},x={id:!0},te=W.partial().required(S).omit(x),j=K.partial().required(S).omit(x),oe=_.partial().required(S).omit(x),re=Q.partial().required(S).required({radius:!0}).omit(x),ne=$.partial().required(S).omit(x),ae=J.partial().required(S).omit(x),ie=X.partial().required(S).required({text:!0}).omit(x).omit({coordinates:!0,name:!0}),se=Y.partial().required(S).required({text:!0}).omit(x).omit({coordinates:!0,name:!0}),mt=ee.partial().required(S).required({imageUrl:!0}).omit(x),Se=e.z.discriminatedUnion("type",[te,j,oe,re,ne,ae,mt,ie,se]),er=W.omit({coordinates:!0}),tr=K.omit({coordinates:!0}),or=_.omit({coordinates:!0}),rr=Q.omit({coordinates:!0}),nr=$.omit({coordinates:!0}),ar=J.omit({coordinates:!0}),ir=X.omit({coordinates:!0}),sr=Y.omit({coordinates:!0}),lr=ee.omit({coordinates:!0}),pr=pt.omit({coordinates:!0}),M={type:!0,id:!0},ct=W.partial().required(M),gt=K.partial().required(M),dt=_.partial().required(M),yt=Q.partial().required(M),ut=$.partial().required(M),ht=J.partial().required(M),ft=X.partial().required(M).omit({coordinates:!0,name:!0}),St=Y.partial().required(M).omit({coordinates:!0,name:!0}),xt=ee.partial().required(M),xe=e.z.discriminatedUnion("type",[ct,gt,dt,yt,ut,ht,ft,St,xt]),Me=e.z.object({ids:e.z.array(e.z.string()).optional()}),be=e.z.object({ids:e.z.array(e.z.string()).optional()});var Mt=t("getElement",y.z.string()),bt=t("getElementGeometry",y.z.string()),Lt=t("getElements",Me.optional()),Ct=t("getElementGroup",y.z.string()),It=t("getElementGroups",be.optional()),Gt=t("setElementGroupVisibility",z),Et=C("onElementChange",y.z.object({id:y.z.string()})),Tt=p("onElementCreate"),zt=C("onElementDelete",y.z.object({id:y.z.string()})),Pt=C("onElementGroupChange",y.z.object({id:y.z.string()})),Ft=t("createElement",Se),kt=t("updateElement",xe),vt=t("deleteElement",y.z.string()),Le={methods:[Mt,bt,Lt,Ct,It,Gt,Ft,kt,vt],listeners:[Et,Tt,zt,Pt]};var wt=p("onPointerClick"),Vt=p("onPointerMove"),Ce={methods:null,listeners:[wt,Vt]};var l=require("zod");var n=require("zod"),Ot=n.z.enum(["in","ni"]),Ut=n.z.enum(["lt","gt","le","ge","eq","ne","cn","nc","is","isnt"]),fr=n.z.enum(["and","or"]),Ie=n.z.union([n.z.number(),n.z.string(),n.z.boolean(),n.z.null()]),Ge=n.z.string().or(n.z.null()),Rt=n.z.tuple([Ge,Ot,n.z.array(Ie).or(n.z.null())]),Nt=n.z.tuple([Ge,Ut,Ie]),le=n.z.union([Rt,Nt]),pe=n.z.tuple([n.z.lazy(()=>n.z.union([pe,le,n.z.null(),n.z.boolean()])),n.z.enum(["and","or"]),n.z.lazy(()=>n.z.union([pe,le,n.z.null(),n.z.boolean()]))]),P=n.z.union([pe,le,n.z.null(),n.z.boolean()]);var o=require("zod");var Ee=o.z.enum(["avg","max","min","sum","median"]),jt=o.z.object({method:Ee,attribute:o.z.string()}),qt=o.z.object({methods:o.z.array(o.z.union([Ee,o.z.literal("count")])),attribute:o.z.string().optional()}),q=o.z.union([T,ye,o.z.array(I)]),Te=o.z.object({boundary:q.optional(),filters:P.optional(),aggregation:jt.optional()}),ze=o.z.object({layerId:o.z.string(),attribute:o.z.string(),limit:o.z.number().optional(),boundary:q.optional(),filters:P.optional(),values:Te.optional()}),br=o.z.object({key:o.z.union([o.z.number(),o.z.string(),o.z.boolean()]),value:o.z.number().nullable()}),At=o.z.object({type:o.z.literal("equal-intervals"),count:o.z.number()}),Ht=o.z.object({type:o.z.literal("time-interval"),interval:o.z.enum(["hour","day","week","month","year"])}),Pe=o.z.object({layerId:o.z.string(),attribute:o.z.string(),steps:o.z.union([At,Ht,o.z.array(o.z.number())]),boundary:q.optional(),filters:P.optional(),values:Te.optional()}),Lr=o.z.object({min:o.z.number(),max:o.z.number(),value:o.z.number()}),Fe=o.z.object({layerId:o.z.string(),boundary:q.optional(),filters:P.optional(),aggregation:qt});var i=require("zod");var Gr=i.z.enum(["processing","completed","failed","incomplete"]),ke=i.z.object({ids:i.z.array(i.z.string()).optional()}),ve=i.z.object({ids:i.z.array(i.z.string()).optional()}),k=i.z.object({id:i.z.string(),layerId:i.z.string()}),we=i.z.object({ids:k.array().optional(),layerIds:i.z.string().array().optional()}),Ve=i.z.object({layerIds:i.z.array(i.z.string()).optional(),areaQuery:i.z.union([i.z.object({coordinates:R}),i.z.object({boundary:T})]).optional()});var Bt=t("getLayer",l.z.string()),Zt=t("getLayers",ke.optional()),Dt=t("setLayerVisibility",z),Wt=C("onLayerChange",l.z.object({id:l.z.string()})),Kt=t("setLayerStyle",l.z.object({id:l.z.string(),style:l.z.object({}).passthrough()})),_t=t("setLayerLegendVisibility",z),Qt=t("getLayerGroup",l.z.string()),$t=t("getLayerGroups",ve.optional()),Jt=t("setLayerGroupVisibility",z),Xt=t("setLayerGroupLegendVisibility",z),Yt=C("onLayerGroupChange",l.z.object({id:l.z.string()})),eo=t("getLegendItem",k),to=t("getLegendItems",we.optional()),oo=C("onLegendItemChange",k),ro=t("setLegendItemVisibility",l.z.object({show:k.array().optional(),hide:k.array().optional()})),no=t("getLayerFilters",l.z.string()),ao=t("setLayerFilters",l.z.object({layerId:l.z.string(),filters:P,note:l.z.string().optional()})),io=t("getRenderedFeatures",Ve.optional()),so=t("getCategoryData",ze),lo=t("getHistogramData",Pe),po=t("getAggregates",Fe),Oe={methods:[Bt,Zt,Dt,Kt,_t,Qt,$t,Jt,Xt,eo,to,ro,no,ao,io,so,lo,po],listeners:[Wt,Yt,oo]};var Ue=require("zod");var mo=t("getMapDetails",Ue.z.undefined()),Re={methods:[mo],listeners:[]};var w=require("zod");var b=require("zod"),Ne=b.z.object({id:b.z.string().or(b.z.number()),layerId:b.z.string(),showPopup:b.z.boolean().optional(),fitViewport:b.z.boolean().or(b.z.object({maxZoom:b.z.number()})).optional()});var co=t("getSelection",w.z.undefined()),go=p("onSelectionChange"),yo=t("selectFeature",Ne),uo=t("clearSelection",w.z.object({features:w.z.boolean().optional(),elements:w.z.boolean().optional()}).optional()),je={methods:[co,yo,uo],listeners:[go]};var Ze=require("zod");var m=require("zod");var qe=["pin","line","route","polygon","circle","marker","highlighter","text","note"],Ae=m.z.enum([...qe,"link"]),He=m.z.enum(qe),ho=te.pick({color:!0,symbol:!0,frame:!0}).required(),fo=j.pick({color:!0,strokeOpacity:!0,strokeWidth:!0,strokeStyle:!0,distanceMarker:!0}).required(),So=j.pick({color:!0,routingMode:!0,strokeOpacity:!0,strokeWidth:!0,strokeStyle:!0,distanceMarker:!0,endCaps:!0}).required(),xo=oe.pick({color:!0,fillOpacity:!0,strokeOpacity:!0,strokeWidth:!0,strokeStyle:!0,areaMarker:!0}).required(),Mo=re.pick({color:!0,fillOpacity:!0,strokeOpacity:!0,strokeWidth:!0,strokeStyle:!0,radiusMarker:!0}).required(),bo=ne.pick({color:!0,opacity:!0,size:!0}).required(),Lo=ae.pick({color:!0,opacity:!0}).extend({size:m.z.number().min(0).max(200)}).required(),Co=ie.pick({color:!0,align:!0,style:!0}).required(),Io=se.pick({color:!0,align:!0,style:!0}).required(),Be=m.z.discriminatedUnion("tool",[ho.partial().extend({tool:m.z.literal("pin")}),fo.partial().extend({tool:m.z.literal("line")}),So.partial().extend({tool:m.z.literal("route")}),xo.partial().extend({tool:m.z.literal("polygon")}),Mo.partial().extend({tool:m.z.literal("circle")}),bo.partial().extend({tool:m.z.literal("marker")}),Lo.partial().extend({tool:m.z.literal("highlighter")}),Co.partial().extend({tool:m.z.literal("text")}),Io.partial().extend({tool:m.z.literal("note")})]);var Go=t("setTool",Ae.nullable()),Eo=t("getTool",Ze.z.undefined()),To=p("onToolChange"),zo=t("setToolSettings",Be),Po=t("getToolSettings",He),Fo=p("onToolSettingsChange"),De={methods:[Go,Eo,zo,Po],listeners:[To,Fo]};var c=require("zod"),We=c.z.object({showLegend:c.z.boolean().optional(),cooperativeGestures:c.z.boolean().optional(),fullScreenButton:c.z.boolean().optional(),geolocation:c.z.boolean().optional(),zoomControls:c.z.boolean().optional(),scaleBar:c.z.boolean().optional()}),Ke=c.z.object({featureSelectPanel:c.z.boolean().optional(),featureHoverPanel:c.z.boolean().optional(),elementSelectPanel:c.z.boolean().optional(),linkClickOpen:c.z.boolean().optional(),imageLightboxOpen:c.z.boolean().optional()});var ko=t("updateUiControls",We),vo=t("setOnMapInteractionsUi",Ke),_e={methods:[ko,vo],listeners:null};var me=require("zod");var V=require("zod");var A=V.z.object({center:R,zoom:ue}),Qe=V.z.object({center:A.shape.center.optional(),zoom:A.shape.zoom.optional()}),$e=V.z.object({minZoom:A.shape.zoom.nullish(),maxZoom:A.shape.zoom.nullish(),bounds:T.nullish()}).nullable(),Je=V.z.object({bounds:T});var wo=t("getViewport",me.z.undefined()),Vo=t("setViewport",Qe),Oo=t("getViewportConstraints",me.z.undefined()),Uo=t("setViewportConstraints",$e),Ro=t("fitViewportToBounds",Je),No=p("onViewportMove"),jo=p("onViewportMoveEnd"),qo=p("onMapIdle"),Xe={methods:[Vo,wo,Oo,Uo,Ro],listeners:[No,jo,qo]};var ce=[_e,Xe,Oe,Le,je,Ce,De,Re];function Ao(r,s,E){let F=new Map;async function L(h){if(!Ko.safeParse(h.data).success){E?.onUnknownMessage?.(h.data);return}let ge=et.safeParse(h.data);if(!ge.success){E?.onInvalidMessage?.(h.data);return}let{data:d}=ge;if(d.type==="felt.ready")h.ports[0]?.postMessage(!0);else if(d.type==="felt.addListener"){if(d.event.eventName==="")throw new Error("felt.addListener eventName cannot be empty");let v="options"in d.event?{options:"options"in d.event?d.event.options:void 0,handler:B=>{h.ports[0]?.postMessage(B)}}:{handler:B=>{h.ports[0]?.postMessage(B)}},H=s.listeners[d.event.eventName](v);F.set(d.event.id,H)}else if(d.type==="felt.removeListener")F.get(d.id)?.(),F.delete(d.id);else try{let v=s.methods[d.type],H=await v(d.params);h.ports[0]?.postMessage(H)}catch(v){h.ports[0]?.postMessage({__error__:Ho(v)})}}return r.addEventListener("message",L),()=>{r.removeEventListener("message",L)}}function Ho(r){return r instanceof Error?r.message:typeof r=="object"&&r!==null&&"message"in r?String(r.message):typeof r=="string"?r:"Unknown error"}var Ye={methods:ce.map(r=>r.methods??[]).flat(),listeners:ce.map(r=>r.listeners??[]).flat()},Bo=g.z.discriminatedUnion("eventName",[g.z.strictObject({eventName:g.z.literal("")}),...Ye.listeners]),Zo=g.z.strictObject({type:g.z.literal("felt.addListener"),event:Bo}),Do=g.z.strictObject({type:g.z.literal("felt.removeListener"),id:g.z.string()}),Wo=g.z.strictObject({type:g.z.literal("felt.ready")}),et=g.z.discriminatedUnion("type",[Wo,Zo,Do,...Ye.methods]),Ko=g.z.object({type:g.z.enum(et.options.map(r=>r.shape.type.value))});0&&(module.exports={createMessageHandler});