@feltmaps/js-sdk 1.5.0-next.18 → 1.5.0-next.19

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/handler.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { z, ZodError } from 'zod';
2
- import { Q as zInfer, E as Element, G as GeoJsonGeometry, b as ElementGroup, d as ElementChangeCallbackParams, e as ElementGroupChangeCallbackParams, M as MapInteractionEvent, L as Layer, m as LayerGroup, q as LegendItem, t as LayerFilters, v as LayerFeature, w as GeoJsonFeature, y as GetLayerCategoriesGroup, A as GetLayerHistogramBin, B as AggregationMethod, D as LayerSchema, i as LayerChangeCallbackParams, o as LayerGroupChangeCallbackParams, s as LegendItemChangeCallbackParams, aB as FilterTernary, H as MapDetails, I as EntityNode, T as ToolType, O as ToolSettingsMap, P as ToolSettingsChangeEvent, V as ViewportState, W as ViewportConstraints, b6 as UnionToIntersection, b7 as PromiseOrNot } from './types-Cy5ifEPb.js';
2
+ import { O as zInfer, E as Element, G as GeoJsonGeometry, b as ElementGroup, d as ElementChangeCallbackParams, e as ElementGroupChangeCallbackParams, M as MapInteractionEvent, L as Layer, j as LayerGroup, n as LegendItem, q as LayerFilters, s as LayerFeature, t as GeoJsonFeature, v as GetLayerCategoriesGroup, x as GetLayerHistogramBin, A as AggregationMethod, z as LayerSchema, i as LayerChangeCallbackParams, l as LayerGroupChangeCallbackParams, p as LegendItemChangeCallbackParams, aI as FilterTernary, B as MapDetails, D as EntityNode, T as ToolType, K as ToolSettingsMap, N as ToolSettingsChangeEvent, V as ViewportState, R as ViewportConstraints, bd as UnionToIntersection, be as PromiseOrNot } from './types-BQxcl9Qq.js';
3
3
 
4
4
  type Method<TRequest extends {
5
5
  type: string;
@@ -1964,73 +1964,39 @@ declare const SetLayerLegendVisibilityMessage: z.ZodObject<{
1964
1964
  }>;
1965
1965
  declare const CreateLayersFromGeoJsonMessage: z.ZodObject<{
1966
1966
  type: z.ZodLiteral<"createLayersFromGeoJson">;
1967
- params: z.ZodUnion<[z.ZodObject<z.objectUtil.extendShape<{
1968
- name: z.ZodString;
1969
- geometryStyles: z.ZodOptional<z.ZodObject<{
1970
- Point: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
1971
- Line: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
1972
- Polygon: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
1967
+ params: z.ZodObject<{
1968
+ source: z.ZodUnion<[z.ZodObject<{
1969
+ type: z.ZodLiteral<"geoJsonUrl">;
1970
+ url: z.ZodString;
1973
1971
  }, "strip", z.ZodTypeAny, {
1974
- Point?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
1975
- Polygon?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
1976
- Line?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
1972
+ type: "geoJsonUrl";
1973
+ url: string;
1977
1974
  }, {
1978
- Point?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
1979
- Polygon?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
1980
- Line?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
1981
- }>>;
1982
- }, {
1983
- arrayBuffer: z.ZodType<ArrayBuffer, z.ZodTypeDef, ArrayBuffer>;
1984
- }>, "strip", z.ZodTypeAny, {
1985
- name: string;
1986
- arrayBuffer: ArrayBuffer;
1987
- geometryStyles?: {
1988
- Point?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
1989
- Polygon?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
1990
- Line?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
1991
- } | undefined;
1992
- }, {
1993
- name: string;
1994
- arrayBuffer: ArrayBuffer;
1995
- geometryStyles?: {
1996
- Point?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
1997
- Polygon?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
1998
- Line?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
1999
- } | undefined;
2000
- }>, z.ZodObject<z.objectUtil.extendShape<{
2001
- name: z.ZodString;
2002
- geometryStyles: z.ZodOptional<z.ZodObject<{
2003
- Point: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
2004
- Line: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
2005
- Polygon: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
1975
+ type: "geoJsonUrl";
1976
+ url: string;
1977
+ }>, z.ZodObject<{
1978
+ type: z.ZodLiteral<"geoJsonData">;
1979
+ data: z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>;
2006
1980
  }, "strip", z.ZodTypeAny, {
2007
- Point?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
2008
- Polygon?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
2009
- Line?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
1981
+ type: "geoJsonData";
1982
+ data: {} & {
1983
+ [k: string]: unknown;
1984
+ };
2010
1985
  }, {
2011
- Point?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
2012
- Polygon?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
2013
- Line?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
2014
- }>>;
2015
- }, {
2016
- file: z.ZodType<File, z.ZodTypeDef, File>;
2017
- }>, "strip", z.ZodTypeAny, {
2018
- name: string;
2019
- file: File;
2020
- geometryStyles?: {
2021
- Point?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
2022
- Polygon?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
2023
- Line?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
2024
- } | undefined;
2025
- }, {
2026
- name: string;
2027
- file: File;
2028
- geometryStyles?: {
2029
- Point?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
2030
- Polygon?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
2031
- Line?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
2032
- } | undefined;
2033
- }>, z.ZodObject<z.objectUtil.extendShape<{
1986
+ type: "geoJsonData";
1987
+ data: {} & {
1988
+ [k: string]: unknown;
1989
+ };
1990
+ }>, z.ZodObject<{
1991
+ type: z.ZodLiteral<"geoJsonFile">;
1992
+ file: z.ZodType<File, z.ZodTypeDef, File>;
1993
+ }, "strip", z.ZodTypeAny, {
1994
+ type: "geoJsonFile";
1995
+ file: File;
1996
+ }, {
1997
+ type: "geoJsonFile";
1998
+ file: File;
1999
+ }>]>;
2034
2000
  name: z.ZodString;
2035
2001
  geometryStyles: z.ZodOptional<z.ZodObject<{
2036
2002
  Point: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
@@ -2045,11 +2011,20 @@ declare const CreateLayersFromGeoJsonMessage: z.ZodObject<{
2045
2011
  Polygon?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
2046
2012
  Line?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
2047
2013
  }>>;
2048
- }, {
2049
- url: z.ZodString;
2050
- }>, "strip", z.ZodTypeAny, {
2014
+ }, "strip", z.ZodTypeAny, {
2051
2015
  name: string;
2052
- url: string;
2016
+ source: {
2017
+ type: "geoJsonUrl";
2018
+ url: string;
2019
+ } | {
2020
+ type: "geoJsonData";
2021
+ data: {} & {
2022
+ [k: string]: unknown;
2023
+ };
2024
+ } | {
2025
+ type: "geoJsonFile";
2026
+ file: File;
2027
+ };
2053
2028
  geometryStyles?: {
2054
2029
  Point?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
2055
2030
  Polygon?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
@@ -2057,33 +2032,39 @@ declare const CreateLayersFromGeoJsonMessage: z.ZodObject<{
2057
2032
  } | undefined;
2058
2033
  }, {
2059
2034
  name: string;
2060
- url: string;
2035
+ source: {
2036
+ type: "geoJsonUrl";
2037
+ url: string;
2038
+ } | {
2039
+ type: "geoJsonData";
2040
+ data: {} & {
2041
+ [k: string]: unknown;
2042
+ };
2043
+ } | {
2044
+ type: "geoJsonFile";
2045
+ file: File;
2046
+ };
2061
2047
  geometryStyles?: {
2062
2048
  Point?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
2063
2049
  Polygon?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
2064
2050
  Line?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
2065
2051
  } | undefined;
2066
- }>]>;
2052
+ }>;
2067
2053
  }, z.UnknownKeysParam, z.ZodTypeAny, {
2068
2054
  params: {
2069
2055
  name: string;
2070
- arrayBuffer: ArrayBuffer;
2071
- geometryStyles?: {
2072
- Point?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
2073
- Polygon?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
2074
- Line?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
2075
- } | undefined;
2076
- } | {
2077
- name: string;
2078
- file: File;
2079
- geometryStyles?: {
2080
- Point?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
2081
- Polygon?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
2082
- Line?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
2083
- } | undefined;
2084
- } | {
2085
- name: string;
2086
- url: string;
2056
+ source: {
2057
+ type: "geoJsonUrl";
2058
+ url: string;
2059
+ } | {
2060
+ type: "geoJsonData";
2061
+ data: {} & {
2062
+ [k: string]: unknown;
2063
+ };
2064
+ } | {
2065
+ type: "geoJsonFile";
2066
+ file: File;
2067
+ };
2087
2068
  geometryStyles?: {
2088
2069
  Point?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
2089
2070
  Polygon?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
@@ -2094,23 +2075,18 @@ declare const CreateLayersFromGeoJsonMessage: z.ZodObject<{
2094
2075
  }, {
2095
2076
  params: {
2096
2077
  name: string;
2097
- arrayBuffer: ArrayBuffer;
2098
- geometryStyles?: {
2099
- Point?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
2100
- Polygon?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
2101
- Line?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
2102
- } | undefined;
2103
- } | {
2104
- name: string;
2105
- file: File;
2106
- geometryStyles?: {
2107
- Point?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
2108
- Polygon?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
2109
- Line?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
2110
- } | undefined;
2111
- } | {
2112
- name: string;
2113
- url: string;
2078
+ source: {
2079
+ type: "geoJsonUrl";
2080
+ url: string;
2081
+ } | {
2082
+ type: "geoJsonData";
2083
+ data: {} & {
2084
+ [k: string]: unknown;
2085
+ };
2086
+ } | {
2087
+ type: "geoJsonFile";
2088
+ file: File;
2089
+ };
2114
2090
  geometryStyles?: {
2115
2091
  Point?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
2116
2092
  Polygon?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
package/dist/handler.js CHANGED
@@ -1 +1 @@
1
- import{z as y}from"zod";import{z as u}from"zod";import{z as x}from"zod";function t(r,I){return x.strictObject({type:x.literal(r),params:I})}function h(r,I){return x.strictObject({eventName:x.literal(r),id:x.string(),options:I})}function l(r){return x.strictObject({eventName:x.literal(r),id:x.string()})}import{z as i}from"zod";var R=i.number(),N=i.number(),j=i.object({latitude:N,longitude:R}),L=i.tuple([R,N]),T=i.object({type:i.literal("Polygon"),coordinates:i.array(i.array(L).min(4).refine(r=>r[0][0]===r[r.length-1][0]&&r[0][1]===r[r.length-1][1],"The last point of each ring must be identical to the first"))}),A=i.object({type:i.literal("MultiPolygon"),coordinates:i.array(T.shape.coordinates)}),rt=i.object({type:i.literal("LineString"),coordinates:i.array(L).min(2)}),F=i.object({type:i.literal("MultiLineString"),coordinates:i.array(rt.shape.coordinates)}),ue=i.number().min(1).max(23),b=i.tuple([R,N,R,N]),C=i.object({show:i.array(i.string()).optional(),hide:i.array(i.string()).optional()}),nt=i.enum(["asc","desc"]),he=i.object({attribute:i.string(),direction:nt});import{z as e}from"zod";var d=e.object({id:e.string(),groupId:e.string().nullable(),color:e.string(),name:e.string().nullable(),description:e.string().nullable(),attributes:e.record(e.string(),e.unknown()),interaction:e.enum(["default","locked"]).optional()}),J=e.object({imageUrl:e.string().nullable()}),ee=e.object({strokeOpacity:e.number(),strokeWidth:e.number(),strokeStyle:e.enum(["solid","dashed","dotted"])}),at=e.enum(["meter","kilometer","foot","mile"]),H=d.extend(J.shape).extend({type:e.literal("Place"),coordinates:L,symbol:e.string(),frame:e.enum(["frame-circle","frame-square"]).nullable(),hideLabel:e.boolean()}),k=d.extend(J.shape).extend(ee.shape).extend({type:e.literal("Path"),coordinates:F.shape.coordinates,distanceMarker:e.boolean(),routingMode:e.enum(["driving","cycling","walking","flying"]).nullable(),endCaps:e.boolean()}),v=d.extend(J.shape).extend(ee.shape).extend({type:e.literal("Polygon"),coordinates:T.shape.coordinates,fillOpacity:e.number().min(0).max(1),areaMarker:e.boolean()}),B=d.extend(J.shape).extend(ee.shape).extend({type:e.literal("Circle"),center:L,radius:e.number(),radiusMarker:e.boolean(),radiusDisplayAngle:e.number(),radiusDisplayUnit:at.nullable(),fillOpacity:e.number().min(0).max(1)}),w=d.extend({type:e.literal("Marker"),coordinates:F.shape.coordinates,opacity:e.number().min(0).max(1),size:e.number().min(0).max(100),zoom:e.number().min(0).max(23)}),V=d.extend({type:e.literal("Highlighter"),coordinates:A.shape.coordinates,renderHoles:e.boolean(),opacity:e.number().min(0).max(1)}),fe=e.object({position:L,rotation:e.number(),scale:e.number(),zoom:e.number().min(0).max(23),coordinates:T.shape.coordinates}),Se=e.object({text:e.string(),align:e.enum(["left","center","right"]),style:e.enum(["italic","light","regular","caps"]),name:e.string()}),D=d.extend(fe.shape).extend(Se.shape).extend({type:e.literal("Text")}),Z=d.extend(fe.shape).extend(Se.shape).extend({type:e.literal("Note"),widthScale:e.number().min(0)}),O=d.extend({type:e.literal("Image"),coordinates:F.shape.coordinates,imageUrl:e.string(),opacity:e.number().min(0).max(1)}).omit({color:!0}),it=d.extend({type:e.literal("Link"),coordinates:F.shape.coordinates,url:e.string()}),E={type:!0,coordinates:!0},f={id:!0},te=H.partial().extend(H.pick(E).shape).omit(f),q=k.partial().extend(k.pick(E).shape).omit(f),oe=v.partial().extend(v.pick(E).shape).omit(f),re=B.partial().extend(B.pick({type:!0,center:!0,radius:!0}).shape).omit(f),ne=w.partial().extend(w.pick(E).shape).omit(f),ae=V.partial().extend(V.pick(E).shape).omit(f),ie=D.partial().omit({...f,coordinates:!0,name:!0,type:!0}).extend({type:e.literal("Text"),text:e.string()}),se=Z.partial().omit({...f,coordinates:!0,name:!0,type:!0}).extend({type:e.literal("Note"),text:e.string()}),st=O.partial().extend(O.pick({...E,imageUrl:!0}).shape).omit(f),xe=e.discriminatedUnion("type",[te,q,oe,re,ne,ae,st,ie,se]);var yr=k.omit({coordinates:!0}),gr=v.omit({coordinates:!0});var dr=w.omit({coordinates:!0}),ur=V.omit({coordinates:!0}),hr=D.omit({coordinates:!0}),fr=Z.omit({coordinates:!0}),Sr=O.omit({coordinates:!0}),xr=it.omit({coordinates:!0}),S={type:!0,id:!0},lt=H.partial().extend(H.pick(S).shape),pt=k.partial().extend(k.pick(S).shape),mt=v.partial().extend(v.pick(S).shape),ct=B.partial().extend(B.pick(S).shape),yt=w.partial().extend(w.pick(S).shape),gt=V.partial().extend(V.pick(S).shape),dt=D.partial().extend(D.pick(S).shape).omit({coordinates:!0,name:!0}),ut=Z.partial().extend(Z.pick(S).shape).omit({coordinates:!0,name:!0}),ht=O.partial().extend(O.pick(S).shape),Le=e.discriminatedUnion("type",[lt,pt,mt,ct,yt,gt,dt,ut,ht]),Me=e.object({ids:e.array(e.string()).optional()}),be=e.object({ids:e.array(e.string()).optional()});var ft=t("getElement",u.string()),St=t("getElementGeometry",u.string()),xt=t("getElements",Me.optional()),Lt=t("getElementGroup",u.string()),Mt=t("getElementGroups",be.optional()),bt=t("setElementGroupVisibility",C),Ct=h("onElementChange",u.object({id:u.string()})),Gt=l("onElementCreate"),It=l("onElementCreateEnd"),Tt=h("onElementDelete",u.object({id:u.string()})),Et=h("onElementGroupChange",u.object({id:u.string()})),zt=t("createElement",xe),Pt=t("updateElement",Le),Ft=t("deleteElement",u.string()),Ce={methods:[ft,St,xt,Lt,Mt,bt,zt,Pt,Ft],listeners:[Ct,Gt,It,Tt,Et]};var kt=l("onPointerClick"),vt=l("onPointerMove"),Ge={methods:null,listeners:[kt,vt]};import{z as s}from"zod";import{z as n}from"zod";var wt=n.enum(["in","ni"]),Vt=n.enum(["lt","gt","le","ge","eq","ne","cn","nc","is","isnt"]),Pr=n.enum(["and","or"]),Ie=n.union([n.number(),n.string(),n.boolean(),n.null()]),Te=n.string().or(n.null()),Ot=n.tuple([Te,wt,n.array(Ie).or(n.null())]),Ut=n.tuple([Te,Vt,Ie]),le=n.union([Ot,Ut]),pe=n.tuple([n.lazy(()=>n.union([pe,le,n.null(),n.boolean()])),n.enum(["and","or"]),n.lazy(()=>n.union([pe,le,n.null(),n.boolean()]))]),G=n.union([pe,le,n.null(),n.boolean()]);import{z as o}from"zod";var Ee=o.enum(["avg","max","min","sum","median"]),Rt=o.object({method:Ee,attribute:o.string()}),Nt=o.object({methods:o.array(o.union([Ee,o.literal("count")])),attribute:o.string().optional()}),W=o.union([b,T,A,o.array(L)]),ze=o.object({boundary:W.optional(),filters:G.optional(),aggregation:Rt.optional()}),Pe=o.object({layerId:o.string(),attribute:o.string(),limit:o.number().optional(),boundary:W.optional(),filters:G.optional(),values:ze.optional()}),Vr=o.object({key:o.union([o.number(),o.string(),o.boolean()]),value:o.number().nullable()}),jt=o.object({type:o.literal("equal-intervals"),count:o.number()}),At=o.object({type:o.literal("time-interval"),interval:o.enum(["hour","day","week","month","year"])}),Fe=o.object({layerId:o.string(),attribute:o.string(),steps:o.union([jt,At,o.array(o.number())]),boundary:W.optional(),filters:G.optional(),values:ze.optional()}),Or=o.object({min:o.number(),max:o.number(),value:o.number()}),ke=o.object({layerId:o.string(),boundary:W.optional(),filters:G.optional(),aggregation:Nt});import{z as a}from"zod";var jr=a.enum(["processing","completed","failed","incomplete"]),ve=a.object({ids:a.array(a.string()).optional()}),we=a.object({ids:a.array(a.string()).optional()}),z=a.object({id:a.string(),layerId:a.string()}),Ve=a.object({ids:z.array().optional(),layerIds:a.string().array().optional()}),Oe=a.object({layerIds:a.array(a.string()).optional(),areaQuery:a.union([a.object({coordinates:j}),a.object({boundary:b})]).optional()}),Ht=a.object({Point:a.object({}).passthrough().optional(),Line:a.object({}).passthrough().optional(),Polygon:a.object({}).passthrough().optional()}),me=a.object({name:a.string(),geometryStyles:Ht.optional()}),Bt=me.extend({file:a.instanceof(File)}),Dt=me.extend({url:a.string().url()}),Zt=me.extend({arrayBuffer:a.instanceof(ArrayBuffer)}),Ue=a.union([Zt,Bt,Dt]);var Jt=t("getLayer",s.string()),qt=t("getLayers",ve.optional()),Wt=t("setLayerVisibility",C),_t=h("onLayerChange",s.object({id:s.string()})),Qt=t("setLayerStyle",s.object({id:s.string(),style:s.object({}).passthrough()})),$t=t("setLayerLegendVisibility",C),Kt=t("createLayersFromGeoJson",Ue),Xt=t("deleteLayer",s.string()),Yt=t("getLayerGroup",s.string()),eo=t("getLayerGroups",we.optional()),to=t("setLayerGroupVisibility",C),oo=t("setLayerGroupLegendVisibility",C),ro=h("onLayerGroupChange",s.object({id:s.string()})),no=t("getLegendItem",z),ao=t("getLegendItems",Ve.optional()),io=h("onLegendItemChange",z),so=t("setLegendItemVisibility",s.object({show:z.array().optional(),hide:z.array().optional()})),lo=t("getLayerFilters",s.string()),po=t("setLayerFilters",s.object({layerId:s.string(),filters:G,note:s.string().optional()})),mo=h("onLayerFiltersChange",s.object({layerId:s.string()})),co=t("getRenderedFeatures",Oe.optional()),yo=t("getFeature",s.object({id:s.string().or(s.number()),layerId:s.string()})),go=t("getGeoJsonFeature",s.object({id:s.string().or(s.number()),layerId:s.string()})),uo=t("getCategoryData",Pe),ho=t("getHistogramData",Fe),fo=t("getAggregates",ke),So=t("getLayerSchema",s.string()),Re={methods:[Jt,qt,Wt,Qt,$t,Kt,Xt,Yt,eo,to,oo,no,ao,so,lo,po,co,yo,go,uo,ho,fo,So],listeners:[_t,ro,io,mo]};import{z as xo}from"zod";var Lo=t("getMapDetails",xo.undefined()),Ne={methods:[Lo],listeners:[]};import{z as _}from"zod";import{z as M}from"zod";var je=M.object({id:M.string().or(M.number()),layerId:M.string(),showPopup:M.boolean().optional(),fitViewport:M.boolean().or(M.object({maxZoom:M.number()})).optional()});var Mo=t("getSelection",_.undefined()),bo=l("onSelectionChange"),Co=t("selectFeature",je),Go=t("clearSelection",_.object({features:_.boolean().optional(),elements:_.boolean().optional()}).optional()),Ae={methods:[Mo,Co,Go],listeners:[bo]};import{z as Vo}from"zod";import{z as p}from"zod";var He=["pin","line","route","polygon","circle","marker","highlighter","text","note"],Be=p.enum([...He,"link"]),De=p.enum(He),Io=te.pick({color:!0,symbol:!0,frame:!0}).extend({afterCreation:p.enum(["enter name","add another","select"])}).required(),To=q.pick({color:!0,strokeOpacity:!0,strokeWidth:!0,strokeStyle:!0,distanceMarker:!0}).required(),Eo=q.pick({color:!0,routingMode:!0,strokeOpacity:!0,strokeWidth:!0,strokeStyle:!0,distanceMarker:!0,endCaps:!0}).required(),zo=oe.pick({color:!0,fillOpacity:!0,strokeOpacity:!0,strokeWidth:!0,strokeStyle:!0,areaMarker:!0}).required(),Po=re.pick({color:!0,fillOpacity:!0,strokeOpacity:!0,strokeWidth:!0,strokeStyle:!0,radiusMarker:!0}).required(),Fo=ne.pick({color:!0,opacity:!0,size:!0}).required(),ko=ae.pick({color:!0,opacity:!0,renderHoles:!0}).extend({size:p.number().min(0).max(200)}).required(),vo=ie.pick({color:!0,align:!0,style:!0}).required(),wo=se.pick({color:!0,align:!0,style:!0}).required(),Ze=p.discriminatedUnion("tool",[Io.partial().extend({tool:p.literal("pin")}),To.partial().extend({tool:p.literal("line")}),Eo.partial().extend({tool:p.literal("route")}),zo.partial().extend({tool:p.literal("polygon")}),Po.partial().extend({tool:p.literal("circle")}),Fo.partial().extend({tool:p.literal("marker")}),ko.partial().extend({tool:p.literal("highlighter")}),vo.partial().extend({tool:p.literal("text")}),wo.partial().extend({tool:p.literal("note")})]);var Oo=t("setTool",Be.nullable()),Uo=t("getTool",Vo.undefined()),Ro=l("onToolChange"),No=t("setToolSettings",Ze),jo=t("getToolSettings",De),Ao=l("onToolSettingsChange"),Je={methods:[Oo,Uo,No,jo],listeners:[Ro,Ao]};import{z as ce}from"zod";import{z as c}from"zod";var qe=c.object({showLegend:c.boolean().optional(),cooperativeGestures:c.boolean().optional(),fullScreenButton:c.boolean().optional(),geolocation:c.boolean().optional(),zoomControls:c.boolean().optional(),scaleBar:c.boolean().optional()}),We=c.object({featureSelectPanel:c.boolean().optional(),featureHoverPanel:c.boolean().optional(),elementSelectPanel:c.boolean().optional(),linkClickOpen:c.boolean().optional(),imageLightboxOpen:c.boolean().optional()});var Ho=t("updateUiControls",qe),Bo=t("setOnMapInteractionsUi",We),Do=t("showLayerDataTable",ce.object({layerId:ce.string(),sorting:he.optional()}).optional()),Zo=t("hideLayerDataTable",ce.undefined()),_e={methods:[Ho,Bo,Do,Zo],listeners:null};import{z as Xe}from"zod";import{z as $}from"zod";var Q=$.object({center:j,zoom:ue}),Qe=$.object({center:Q.shape.center.optional(),zoom:Q.shape.zoom.optional()}),$e=$.object({minZoom:Q.shape.zoom.nullish(),maxZoom:Q.shape.zoom.nullish(),bounds:b.nullish()}).nullable(),Ke=$.object({bounds:b});var Jo=t("getViewport",Xe.undefined()),qo=t("setViewport",Qe),Wo=t("getViewportConstraints",Xe.undefined()),_o=t("setViewportConstraints",$e),Qo=t("fitViewportToBounds",Ke),$o=l("onViewportMove"),Ko=l("onViewportMoveEnd"),Xo=l("onMapIdle"),Ye={methods:[qo,Jo,Wo,_o,Qo],listeners:[$o,Ko,Xo]};var ye=[_e,Ye,Re,Ce,Ae,Ge,Je,Ne];function Rn(r,I,ge){let K=new Map;async function de(g){if(!rr.safeParse(g.data).success){ge?.onUnknownMessage?.(g.data);return}let U=ot.safeParse(g.data);if(!U.success){ge?.onInvalidMessage?.(g.data,U.error),g.ports[0]?.postMessage(et(U.error.message));return}let{data:m}=U;if(m.type==="felt.ready")g.ports[0]?.postMessage(!0);else if(m.type==="felt.addListener"){if(m.event.eventName==="")throw new Error("felt.addListener eventName cannot be empty");let P="options"in m.event?{options:"options"in m.event?m.event.options:void 0,handler:Y=>{g.ports[0]?.postMessage(Y)}}:{handler:Y=>{g.ports[0]?.postMessage(Y)}},X=I.listeners[m.event.eventName](P);K.set(m.event.id,X)}else if(m.type==="felt.removeListener")K.get(m.id)?.(),K.delete(m.id);else try{let P=I.methods[m.type],X=await P(m.params);g.ports[0]?.postMessage(X)}catch(P){g.ports[0]?.postMessage(et(P))}}return r.addEventListener("message",de),()=>{r.removeEventListener("message",de)}}var tt={methods:ye.map(r=>r.methods??[]).flat(),listeners:ye.map(r=>r.listeners??[]).flat()},Yo=y.discriminatedUnion("eventName",[y.strictObject({eventName:y.literal("")}),...tt.listeners]),er=y.strictObject({type:y.literal("felt.addListener"),event:Yo}),tr=y.strictObject({type:y.literal("felt.removeListener"),id:y.string()}),or=y.strictObject({type:y.literal("felt.ready")}),ot=y.discriminatedUnion("type",[or,er,tr,...tt.methods]),rr=y.object({type:y.enum(ot.options.map(r=>r.shape.type.value))});function et(r){return{__error__:nr(r)}}function nr(r){return r instanceof Error?r.message:typeof r=="object"&&r!==null&&"message"in r?String(r.message):typeof r=="string"?r:"Unknown error"}export{Rn as createMessageHandler};
1
+ import{z as y}from"zod";import{z as u}from"zod";import{z as x}from"zod";function t(n,I){return x.strictObject({type:x.literal(n),params:I})}function h(n,I){return x.strictObject({eventName:x.literal(n),id:x.string(),options:I})}function l(n){return x.strictObject({eventName:x.literal(n),id:x.string()})}import{z as i}from"zod";var j=i.number(),R=i.number(),N=i.object({latitude:R,longitude:j}),L=i.tuple([j,R]),T=i.object({type:i.literal("Polygon"),coordinates:i.array(i.array(L).min(4).refine(n=>n[0][0]===n[n.length-1][0]&&n[0][1]===n[n.length-1][1],"The last point of each ring must be identical to the first"))}),A=i.object({type:i.literal("MultiPolygon"),coordinates:i.array(T.shape.coordinates)}),ot=i.object({type:i.literal("LineString"),coordinates:i.array(L).min(2)}),F=i.object({type:i.literal("MultiLineString"),coordinates:i.array(ot.shape.coordinates)}),de=i.number().min(1).max(23),M=i.tuple([j,R,j,R]),C=i.object({show:i.array(i.string()).optional(),hide:i.array(i.string()).optional()}),rt=i.enum(["asc","desc"]),ue=i.object({attribute:i.string(),direction:rt});import{z as e}from"zod";var d=e.object({id:e.string(),groupId:e.string().nullable(),color:e.string(),name:e.string().nullable(),description:e.string().nullable(),attributes:e.record(e.string(),e.unknown()),interaction:e.enum(["default","locked"]).optional()}),Z=e.object({imageUrl:e.string().nullable()}),ee=e.object({strokeOpacity:e.number(),strokeWidth:e.number(),strokeStyle:e.enum(["solid","dashed","dotted"])}),nt=e.enum(["meter","kilometer","foot","mile"]),D=d.extend(Z.shape).extend({type:e.literal("Place"),coordinates:L,symbol:e.string(),frame:e.enum(["frame-circle","frame-square"]).nullable(),hideLabel:e.boolean()}),k=d.extend(Z.shape).extend(ee.shape).extend({type:e.literal("Path"),coordinates:F.shape.coordinates,distanceMarker:e.boolean(),routingMode:e.enum(["driving","cycling","walking","flying"]).nullable(),endCaps:e.boolean()}),V=d.extend(Z.shape).extend(ee.shape).extend({type:e.literal("Polygon"),coordinates:T.shape.coordinates,fillOpacity:e.number().min(0).max(1),areaMarker:e.boolean()}),H=d.extend(Z.shape).extend(ee.shape).extend({type:e.literal("Circle"),center:L,radius:e.number(),radiusMarker:e.boolean(),radiusDisplayAngle:e.number(),radiusDisplayUnit:nt.nullable(),fillOpacity:e.number().min(0).max(1)}),v=d.extend({type:e.literal("Marker"),coordinates:F.shape.coordinates,opacity:e.number().min(0).max(1),size:e.number().min(0).max(100),zoom:e.number().min(0).max(23)}),w=d.extend({type:e.literal("Highlighter"),coordinates:A.shape.coordinates,renderHoles:e.boolean(),opacity:e.number().min(0).max(1)}),he=e.object({position:L,rotation:e.number(),scale:e.number(),zoom:e.number().min(0).max(23),coordinates:T.shape.coordinates}),fe=e.object({text:e.string(),align:e.enum(["left","center","right"]),style:e.enum(["italic","light","regular","caps"]),name:e.string()}),J=d.extend(he.shape).extend(fe.shape).extend({type:e.literal("Text")}),B=d.extend(he.shape).extend(fe.shape).extend({type:e.literal("Note"),widthScale:e.number().min(0)}),O=d.extend({type:e.literal("Image"),coordinates:F.shape.coordinates,imageUrl:e.string(),opacity:e.number().min(0).max(1)}).omit({color:!0}),at=d.extend({type:e.literal("Link"),coordinates:F.shape.coordinates,url:e.string()}),E={type:!0,coordinates:!0},f={id:!0},te=D.partial().extend(D.pick(E).shape).omit(f),q=k.partial().extend(k.pick(E).shape).omit(f),oe=V.partial().extend(V.pick(E).shape).omit(f),re=H.partial().extend(H.pick({type:!0,center:!0,radius:!0}).shape).omit(f),ne=v.partial().extend(v.pick(E).shape).omit(f),ae=w.partial().extend(w.pick(E).shape).omit(f),ie=J.partial().omit({...f,coordinates:!0,name:!0,type:!0}).extend({type:e.literal("Text"),text:e.string()}),se=B.partial().omit({...f,coordinates:!0,name:!0,type:!0}).extend({type:e.literal("Note"),text:e.string()}),it=O.partial().extend(O.pick({...E,imageUrl:!0}).shape).omit(f),Se=e.discriminatedUnion("type",[te,q,oe,re,ne,ae,it,ie,se]);var cr=k.omit({coordinates:!0}),yr=V.omit({coordinates:!0});var gr=v.omit({coordinates:!0}),dr=w.omit({coordinates:!0}),ur=J.omit({coordinates:!0}),hr=B.omit({coordinates:!0}),fr=O.omit({coordinates:!0}),Sr=at.omit({coordinates:!0}),S={type:!0,id:!0},st=D.partial().extend(D.pick(S).shape),lt=k.partial().extend(k.pick(S).shape),pt=V.partial().extend(V.pick(S).shape),mt=H.partial().extend(H.pick(S).shape),ct=v.partial().extend(v.pick(S).shape),yt=w.partial().extend(w.pick(S).shape),gt=J.partial().extend(J.pick(S).shape).omit({coordinates:!0,name:!0}),dt=B.partial().extend(B.pick(S).shape).omit({coordinates:!0,name:!0}),ut=O.partial().extend(O.pick(S).shape),xe=e.discriminatedUnion("type",[st,lt,pt,mt,ct,yt,gt,dt,ut]),Le=e.object({ids:e.array(e.string()).optional()}),be=e.object({ids:e.array(e.string()).optional()});var ht=t("getElement",u.string()),ft=t("getElementGeometry",u.string()),St=t("getElements",Le.optional()),xt=t("getElementGroup",u.string()),Lt=t("getElementGroups",be.optional()),bt=t("setElementGroupVisibility",C),Mt=h("onElementChange",u.object({id:u.string()})),Ct=l("onElementCreate"),Gt=l("onElementCreateEnd"),It=h("onElementDelete",u.object({id:u.string()})),Tt=h("onElementGroupChange",u.object({id:u.string()})),Et=t("createElement",Se),zt=t("updateElement",xe),Pt=t("deleteElement",u.string()),Me={methods:[ht,ft,St,xt,Lt,bt,Et,zt,Pt],listeners:[Mt,Ct,Gt,It,Tt]};var Ft=l("onPointerClick"),kt=l("onPointerMove"),Ce={methods:null,listeners:[Ft,kt]};import{z as s}from"zod";import{z as a}from"zod";var Vt=a.enum(["in","ni"]),vt=a.enum(["lt","gt","le","ge","eq","ne","cn","nc","is","isnt"]),zr=a.enum(["and","or"]),Ge=a.union([a.number(),a.string(),a.boolean(),a.null()]),Ie=a.string().or(a.null()),wt=a.tuple([Ie,Vt,a.array(Ge).or(a.null())]),Ot=a.tuple([Ie,vt,Ge]),le=a.union([wt,Ot]),pe=a.tuple([a.lazy(()=>a.union([pe,le,a.null(),a.boolean()])),a.enum(["and","or"]),a.lazy(()=>a.union([pe,le,a.null(),a.boolean()]))]),G=a.union([pe,le,a.null(),a.boolean()]);import{z as o}from"zod";var Te=o.enum(["avg","max","min","sum","median"]),Ut=o.object({method:Te,attribute:o.string()}),jt=o.object({methods:o.array(o.union([Te,o.literal("count")])),attribute:o.string().optional()}),W=o.union([M,T,A,o.array(L)]),Ee=o.object({boundary:W.optional(),filters:G.optional(),aggregation:Ut.optional()}),ze=o.object({layerId:o.string(),attribute:o.string(),limit:o.number().optional(),boundary:W.optional(),filters:G.optional(),values:Ee.optional()}),vr=o.object({key:o.union([o.number(),o.string(),o.boolean()]),value:o.number().nullable()}),Rt=o.object({type:o.literal("equal-intervals"),count:o.number()}),Nt=o.object({type:o.literal("time-interval"),interval:o.enum(["hour","day","week","month","year"])}),Pe=o.object({layerId:o.string(),attribute:o.string(),steps:o.union([Rt,Nt,o.array(o.number())]),boundary:W.optional(),filters:G.optional(),values:Ee.optional()}),wr=o.object({min:o.number(),max:o.number(),value:o.number()}),Fe=o.object({layerId:o.string(),boundary:W.optional(),filters:G.optional(),aggregation:jt});import{z as r}from"zod";var Rr=r.enum(["processing","completed","failed","incomplete"]),At=r.object({type:r.literal("geoJsonUrl"),url:r.string().url()}),Dt=r.object({type:r.literal("geoJsonData"),data:r.object({}).passthrough()}),Ht=r.object({type:r.literal("geoJsonFile"),file:r.instanceof(File)}),ke=r.object({ids:r.array(r.string()).optional()}),Ve=r.object({ids:r.array(r.string()).optional()}),z=r.object({id:r.string(),layerId:r.string()}),ve=r.object({ids:z.array().optional(),layerIds:r.string().array().optional()}),we=r.object({layerIds:r.array(r.string()).optional(),areaQuery:r.union([r.object({coordinates:N}),r.object({boundary:M})]).optional()}),Jt=r.object({Point:r.object({}).passthrough().optional(),Line:r.object({}).passthrough().optional(),Polygon:r.object({}).passthrough().optional()}),Oe=r.object({source:r.union([At,Dt,Ht]),name:r.string(),geometryStyles:Jt.optional()});var Bt=t("getLayer",s.string()),Zt=t("getLayers",ke.optional()),qt=t("setLayerVisibility",C),Wt=h("onLayerChange",s.object({id:s.string()})),_t=t("setLayerStyle",s.object({id:s.string(),style:s.object({}).passthrough()})),Qt=t("setLayerLegendVisibility",C),$t=t("createLayersFromGeoJson",Oe),Kt=t("deleteLayer",s.string()),Xt=t("getLayerGroup",s.string()),Yt=t("getLayerGroups",Ve.optional()),eo=t("setLayerGroupVisibility",C),to=t("setLayerGroupLegendVisibility",C),oo=h("onLayerGroupChange",s.object({id:s.string()})),ro=t("getLegendItem",z),no=t("getLegendItems",ve.optional()),ao=h("onLegendItemChange",z),io=t("setLegendItemVisibility",s.object({show:z.array().optional(),hide:z.array().optional()})),so=t("getLayerFilters",s.string()),lo=t("setLayerFilters",s.object({layerId:s.string(),filters:G,note:s.string().optional()})),po=h("onLayerFiltersChange",s.object({layerId:s.string()})),mo=t("getRenderedFeatures",we.optional()),co=t("getFeature",s.object({id:s.string().or(s.number()),layerId:s.string()})),yo=t("getGeoJsonFeature",s.object({id:s.string().or(s.number()),layerId:s.string()})),go=t("getCategoryData",ze),uo=t("getHistogramData",Pe),ho=t("getAggregates",Fe),fo=t("getLayerSchema",s.string()),Ue={methods:[Bt,Zt,qt,_t,Qt,$t,Kt,Xt,Yt,eo,to,ro,no,io,so,lo,mo,co,yo,go,uo,ho,fo],listeners:[Wt,oo,ao,po]};import{z as So}from"zod";var xo=t("getMapDetails",So.undefined()),je={methods:[xo],listeners:[]};import{z as _}from"zod";import{z as b}from"zod";var Re=b.object({id:b.string().or(b.number()),layerId:b.string(),showPopup:b.boolean().optional(),fitViewport:b.boolean().or(b.object({maxZoom:b.number()})).optional()});var Lo=t("getSelection",_.undefined()),bo=l("onSelectionChange"),Mo=t("selectFeature",Re),Co=t("clearSelection",_.object({features:_.boolean().optional(),elements:_.boolean().optional()}).optional()),Ne={methods:[Lo,Mo,Co],listeners:[bo]};import{z as vo}from"zod";import{z as p}from"zod";var Ae=["pin","line","route","polygon","circle","marker","highlighter","text","note"],De=p.enum([...Ae,"link"]),He=p.enum(Ae),Go=te.pick({color:!0,symbol:!0,frame:!0}).extend({afterCreation:p.enum(["enter name","add another","select"])}).required(),Io=q.pick({color:!0,strokeOpacity:!0,strokeWidth:!0,strokeStyle:!0,distanceMarker:!0}).required(),To=q.pick({color:!0,routingMode:!0,strokeOpacity:!0,strokeWidth:!0,strokeStyle:!0,distanceMarker:!0,endCaps:!0}).required(),Eo=oe.pick({color:!0,fillOpacity:!0,strokeOpacity:!0,strokeWidth:!0,strokeStyle:!0,areaMarker:!0}).required(),zo=re.pick({color:!0,fillOpacity:!0,strokeOpacity:!0,strokeWidth:!0,strokeStyle:!0,radiusMarker:!0}).required(),Po=ne.pick({color:!0,opacity:!0,size:!0}).required(),Fo=ae.pick({color:!0,opacity:!0,renderHoles:!0}).extend({size:p.number().min(0).max(200)}).required(),ko=ie.pick({color:!0,align:!0,style:!0}).required(),Vo=se.pick({color:!0,align:!0,style:!0}).required(),Je=p.discriminatedUnion("tool",[Go.partial().extend({tool:p.literal("pin")}),Io.partial().extend({tool:p.literal("line")}),To.partial().extend({tool:p.literal("route")}),Eo.partial().extend({tool:p.literal("polygon")}),zo.partial().extend({tool:p.literal("circle")}),Po.partial().extend({tool:p.literal("marker")}),Fo.partial().extend({tool:p.literal("highlighter")}),ko.partial().extend({tool:p.literal("text")}),Vo.partial().extend({tool:p.literal("note")})]);var wo=t("setTool",De.nullable()),Oo=t("getTool",vo.undefined()),Uo=l("onToolChange"),jo=t("setToolSettings",Je),Ro=t("getToolSettings",He),No=l("onToolSettingsChange"),Be={methods:[wo,Oo,jo,Ro],listeners:[Uo,No]};import{z as me}from"zod";import{z as c}from"zod";var Ze=c.object({showLegend:c.boolean().optional(),cooperativeGestures:c.boolean().optional(),fullScreenButton:c.boolean().optional(),geolocation:c.boolean().optional(),zoomControls:c.boolean().optional(),scaleBar:c.boolean().optional()}),qe=c.object({featureSelectPanel:c.boolean().optional(),featureHoverPanel:c.boolean().optional(),elementSelectPanel:c.boolean().optional(),linkClickOpen:c.boolean().optional(),imageLightboxOpen:c.boolean().optional()});var Ao=t("updateUiControls",Ze),Do=t("setOnMapInteractionsUi",qe),Ho=t("showLayerDataTable",me.object({layerId:me.string(),sorting:ue.optional()}).optional()),Jo=t("hideLayerDataTable",me.undefined()),We={methods:[Ao,Do,Ho,Jo],listeners:null};import{z as Ke}from"zod";import{z as $}from"zod";var Q=$.object({center:N,zoom:de}),_e=$.object({center:Q.shape.center.optional(),zoom:Q.shape.zoom.optional()}),Qe=$.object({minZoom:Q.shape.zoom.nullish(),maxZoom:Q.shape.zoom.nullish(),bounds:M.nullish()}).nullable(),$e=$.object({bounds:M});var Bo=t("getViewport",Ke.undefined()),Zo=t("setViewport",_e),qo=t("getViewportConstraints",Ke.undefined()),Wo=t("setViewportConstraints",Qe),_o=t("fitViewportToBounds",$e),Qo=l("onViewportMove"),$o=l("onViewportMoveEnd"),Ko=l("onMapIdle"),Xe={methods:[Zo,Bo,qo,Wo,_o],listeners:[Qo,$o,Ko]};var ce=[We,Xe,Ue,Me,Ne,Ce,Be,je];function Un(n,I,ye){let K=new Map;async function ge(g){if(!or.safeParse(g.data).success){ye?.onUnknownMessage?.(g.data);return}let U=tt.safeParse(g.data);if(!U.success){ye?.onInvalidMessage?.(g.data,U.error),g.ports[0]?.postMessage(Ye(U.error.message));return}let{data:m}=U;if(m.type==="felt.ready")g.ports[0]?.postMessage(!0);else if(m.type==="felt.addListener"){if(m.event.eventName==="")throw new Error("felt.addListener eventName cannot be empty");let P="options"in m.event?{options:"options"in m.event?m.event.options:void 0,handler:Y=>{g.ports[0]?.postMessage(Y)}}:{handler:Y=>{g.ports[0]?.postMessage(Y)}},X=I.listeners[m.event.eventName](P);K.set(m.event.id,X)}else if(m.type==="felt.removeListener")K.get(m.id)?.(),K.delete(m.id);else try{let P=I.methods[m.type],X=await P(m.params);g.ports[0]?.postMessage(X)}catch(P){g.ports[0]?.postMessage(Ye(P))}}return n.addEventListener("message",ge),()=>{n.removeEventListener("message",ge)}}var et={methods:ce.map(n=>n.methods??[]).flat(),listeners:ce.map(n=>n.listeners??[]).flat()},Xo=y.discriminatedUnion("eventName",[y.strictObject({eventName:y.literal("")}),...et.listeners]),Yo=y.strictObject({type:y.literal("felt.addListener"),event:Xo}),er=y.strictObject({type:y.literal("felt.removeListener"),id:y.string()}),tr=y.strictObject({type:y.literal("felt.ready")}),tt=y.discriminatedUnion("type",[tr,Yo,er,...et.methods]),or=y.object({type:y.enum(tt.options.map(n=>n.shape.type.value))});function Ye(n){return{__error__:rr(n)}}function rr(n){return n instanceof Error?n.message:typeof n=="object"&&n!==null&&"message"in n?String(n.message):typeof n=="string"?n:"Unknown error"}export{Un as createMessageHandler};