react-listing-engine 0.6.9 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,11 @@
1
- import { a as MapProvider, c as MapHandle, R as RenderedLayer, B as Bounds, d as MapInitOptions, U as Unsubscribe, b as EntityAdapter, L as LatLng, E as EntityId, e as PageRequest, P as Page, M as MapPoint } from '../map-provider.interface-DT-v1plm.cjs';
1
+ import { a as MapProvider, c as MapHandle, R as RenderedLayer, B as Bounds, E as EntityId, L as LatLng, d as MapInitOptions, U as Unsubscribe, e as MapOverlayHandle, b as EntityAdapter, f as PageRequest, P as Page, M as MapPoint } from '../map-provider.interface-B5Law7gE.cjs';
2
2
 
3
3
  type BoundsListener = (b: Bounds) => void;
4
+ /** One live overlay record kept by `FakeMapProvider.mountOverlay` for assertions. */
5
+ interface FakeOverlay {
6
+ container: HTMLElement;
7
+ position: LatLng;
8
+ }
4
9
  /**
5
10
  * Headless in-memory `MapProvider` test double. Records everything it is
6
11
  * asked to do (mounts, rendered layers, fitBounds calls, destroys) into
@@ -14,14 +19,45 @@ declare class FakeMapProvider implements MapProvider {
14
19
  readonly fitBoundsCalls: Bounds[];
15
20
  readonly destroyed: MapHandle[];
16
21
  destroyCount: number;
22
+ /** Records the most recent `updateMarkerStates` call -- `null` until it is first called. */
23
+ markerStates: {
24
+ selected: EntityId | null;
25
+ hovered: EntityId | null;
26
+ } | null;
27
+ /**
28
+ * Currently-live overlays created via `mountOverlay` (removed on `unmount`),
29
+ * newest last -- lets a test assert an overlay was mounted/anchored/torn down.
30
+ */
31
+ readonly overlays: FakeOverlay[];
32
+ /** Records each `zoomIn`/`zoomOut` call, in order, for assertions. */
33
+ readonly zoomCalls: Array<'in' | 'out'>;
34
+ /** Counts `toggleFullscreen` calls. */
35
+ fullscreenToggles: number;
36
+ /**
37
+ * The Fullscreen API target recorded from the most recent `mount()` call -- mirrors the real
38
+ * `googleProvider`'s `opts.fullscreenTarget ?? el` resolution (see
39
+ * `MapInitOptions.fullscreenTarget`'s doc comment), so a test can assert which element a caller
40
+ * (e.g. `ListingMap`) passed as the fullscreen target -- the OUTER wrapper that also contains
41
+ * the `mapControls` overlay, not the map mount `el` alone.
42
+ */
43
+ fullscreenTarget: HTMLElement | undefined;
17
44
  private readonly boundsListeners;
45
+ private readonly mapClickListeners;
18
46
  mount(el: HTMLElement, opts: MapInitOptions): MapHandle;
19
47
  renderLayer(_handle: MapHandle, layer: RenderedLayer): Unsubscribe;
20
48
  onBoundsChange(_handle: MapHandle, cb: BoundsListener): Unsubscribe;
21
49
  /** Test-only: simulates a user pan/zoom by invoking every registered bounds listener. */
22
50
  emitBounds(b: Bounds): void;
51
+ onMapClick(cb: () => void): Unsubscribe;
52
+ /** Test-only: simulates a click on the map background by invoking every registered map-click listener. */
53
+ emitMapClick(): void;
23
54
  fitBounds(_handle: MapHandle, b: Bounds): void;
24
55
  destroy(handle: MapHandle): void;
56
+ updateMarkerStates(selectedId: EntityId | null, hoveredId: EntityId | null): void;
57
+ mountOverlay(position: LatLng): MapOverlayHandle;
58
+ zoomIn(): void;
59
+ zoomOut(): void;
60
+ toggleFullscreen(): void;
25
61
  }
26
62
 
27
63
  /**
@@ -1,6 +1,11 @@
1
- import { a as MapProvider, c as MapHandle, R as RenderedLayer, B as Bounds, d as MapInitOptions, U as Unsubscribe, b as EntityAdapter, L as LatLng, E as EntityId, e as PageRequest, P as Page, M as MapPoint } from '../map-provider.interface-DT-v1plm.js';
1
+ import { a as MapProvider, c as MapHandle, R as RenderedLayer, B as Bounds, E as EntityId, L as LatLng, d as MapInitOptions, U as Unsubscribe, e as MapOverlayHandle, b as EntityAdapter, f as PageRequest, P as Page, M as MapPoint } from '../map-provider.interface-B5Law7gE.js';
2
2
 
3
3
  type BoundsListener = (b: Bounds) => void;
4
+ /** One live overlay record kept by `FakeMapProvider.mountOverlay` for assertions. */
5
+ interface FakeOverlay {
6
+ container: HTMLElement;
7
+ position: LatLng;
8
+ }
4
9
  /**
5
10
  * Headless in-memory `MapProvider` test double. Records everything it is
6
11
  * asked to do (mounts, rendered layers, fitBounds calls, destroys) into
@@ -14,14 +19,45 @@ declare class FakeMapProvider implements MapProvider {
14
19
  readonly fitBoundsCalls: Bounds[];
15
20
  readonly destroyed: MapHandle[];
16
21
  destroyCount: number;
22
+ /** Records the most recent `updateMarkerStates` call -- `null` until it is first called. */
23
+ markerStates: {
24
+ selected: EntityId | null;
25
+ hovered: EntityId | null;
26
+ } | null;
27
+ /**
28
+ * Currently-live overlays created via `mountOverlay` (removed on `unmount`),
29
+ * newest last -- lets a test assert an overlay was mounted/anchored/torn down.
30
+ */
31
+ readonly overlays: FakeOverlay[];
32
+ /** Records each `zoomIn`/`zoomOut` call, in order, for assertions. */
33
+ readonly zoomCalls: Array<'in' | 'out'>;
34
+ /** Counts `toggleFullscreen` calls. */
35
+ fullscreenToggles: number;
36
+ /**
37
+ * The Fullscreen API target recorded from the most recent `mount()` call -- mirrors the real
38
+ * `googleProvider`'s `opts.fullscreenTarget ?? el` resolution (see
39
+ * `MapInitOptions.fullscreenTarget`'s doc comment), so a test can assert which element a caller
40
+ * (e.g. `ListingMap`) passed as the fullscreen target -- the OUTER wrapper that also contains
41
+ * the `mapControls` overlay, not the map mount `el` alone.
42
+ */
43
+ fullscreenTarget: HTMLElement | undefined;
17
44
  private readonly boundsListeners;
45
+ private readonly mapClickListeners;
18
46
  mount(el: HTMLElement, opts: MapInitOptions): MapHandle;
19
47
  renderLayer(_handle: MapHandle, layer: RenderedLayer): Unsubscribe;
20
48
  onBoundsChange(_handle: MapHandle, cb: BoundsListener): Unsubscribe;
21
49
  /** Test-only: simulates a user pan/zoom by invoking every registered bounds listener. */
22
50
  emitBounds(b: Bounds): void;
51
+ onMapClick(cb: () => void): Unsubscribe;
52
+ /** Test-only: simulates a click on the map background by invoking every registered map-click listener. */
53
+ emitMapClick(): void;
23
54
  fitBounds(_handle: MapHandle, b: Bounds): void;
24
55
  destroy(handle: MapHandle): void;
56
+ updateMarkerStates(selectedId: EntityId | null, hoveredId: EntityId | null): void;
57
+ mountOverlay(position: LatLng): MapOverlayHandle;
58
+ zoomIn(): void;
59
+ zoomOut(): void;
60
+ toggleFullscreen(): void;
25
61
  }
26
62
 
27
63
  /**
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- var o=class{mounts=[];renderedLayers=[];removedLayers=[];fitBoundsCalls=[];destroyed=[];destroyCount=0;boundsListeners=new Set;mount(t,e){let n={raw:{el:t,opts:e}};return this.mounts.push(n),n}renderLayer(t,e){this.renderedLayers.push(e);let n=!1;return()=>{if(n)return;n=!0;let s=this.renderedLayers.indexOf(e);s!==-1&&(this.renderedLayers.splice(s,1),this.removedLayers.push(e))}}onBoundsChange(t,e){return this.boundsListeners.add(e),()=>{this.boundsListeners.delete(e)}}emitBounds(t){for(let e of this.boundsListeners)e(t)}fitBounds(t,e){this.fitBoundsCalls.push(e)}destroy(t){this.destroyed.push(t),this.destroyCount+=1,this.boundsListeners.clear()}};var d=class{constructor(t,e,n,s=r=>r.id){this.rows=t;this.predicate=e;this.toLatLng=n;this.idOf=s}rows;predicate;toLatLng;idOf;async list(t,e){let n=this.rows.filter(u=>this.predicate(u,t)),s=e.cursor==null?0:Number(e.cursor)+1,r=n.slice(s,s+e.limit),i=s+r.length-1,l=i+1<n.length;return{items:r,nextCursor:l?String(i):null,total:n.length}}async getPoints(t,e){let s=this.rows.filter(r=>this.predicate(r,t)).map(r=>({id:this.idOf(r),position:this.toLatLng(r),entity:r}));return e?s.filter(r=>this.isInBounds(r.position,e)):s}async getById(t){let e=this.rows.find(n=>this.idOf(n)===t);if(!e)throw new Error(`InMemoryEntityAdapter: no row with id "${String(t)}"`);return e}isInBounds(t,e){return t.lat<=e.north&&t.lat>=e.south&&t.lng>=e.west&&t.lng<=e.east}};export{o as FakeMapProvider,d as InMemoryEntityAdapter};
2
+ var o=class{mounts=[];renderedLayers=[];removedLayers=[];fitBoundsCalls=[];destroyed=[];destroyCount=0;markerStates=null;overlays=[];zoomCalls=[];fullscreenToggles=0;fullscreenTarget;boundsListeners=new Set;mapClickListeners=new Set;mount(t,e){let n={raw:{el:t,opts:e}};return this.mounts.push(n),this.fullscreenTarget=e.fullscreenTarget??t,n}renderLayer(t,e){this.renderedLayers.push(e);let n=!1;return()=>{if(n)return;n=!0;let s=this.renderedLayers.indexOf(e);s!==-1&&(this.renderedLayers.splice(s,1),this.removedLayers.push(e))}}onBoundsChange(t,e){return this.boundsListeners.add(e),()=>{this.boundsListeners.delete(e)}}emitBounds(t){for(let e of this.boundsListeners)e(t)}onMapClick(t){return this.mapClickListeners.add(t),()=>{this.mapClickListeners.delete(t)}}emitMapClick(){for(let t of this.mapClickListeners)t()}fitBounds(t,e){this.fitBoundsCalls.push(e)}destroy(t){this.destroyed.push(t),this.destroyCount+=1,this.boundsListeners.clear(),this.mapClickListeners.clear()}updateMarkerStates(t,e){this.markerStates={selected:t,hovered:e}}mountOverlay(t){let e=document.createElement("div");document.body.appendChild(e);let n={container:e,position:t};return this.overlays.push(n),{container:e,setPosition:s=>{n.position=s},unmount:()=>{e.remove();let s=this.overlays.indexOf(n);s!==-1&&this.overlays.splice(s,1)}}}zoomIn(){this.zoomCalls.push("in")}zoomOut(){this.zoomCalls.push("out")}toggleFullscreen(){this.fullscreenToggles+=1,this.fullscreenTarget&&typeof this.fullscreenTarget.requestFullscreen=="function"&&this.fullscreenTarget.requestFullscreen()?.catch(()=>{})}};var a=class{constructor(t,e,n,s=r=>r.id){this.rows=t;this.predicate=e;this.toLatLng=n;this.idOf=s}rows;predicate;toLatLng;idOf;async list(t,e){let n=this.rows.filter(u=>this.predicate(u,t)),s=e.cursor==null?0:Number(e.cursor)+1,r=n.slice(s,s+e.limit),i=s+r.length-1,l=i+1<n.length;return{items:r,nextCursor:l?String(i):null,total:n.length}}async getPoints(t,e){let s=this.rows.filter(r=>this.predicate(r,t)).map(r=>({id:this.idOf(r),position:this.toLatLng(r),entity:r}));return e?s.filter(r=>this.isInBounds(r.position,e)):s}async getById(t){let e=this.rows.find(n=>this.idOf(n)===t);if(!e)throw new Error(`InMemoryEntityAdapter: no row with id "${String(t)}"`);return e}isInBounds(t,e){return t.lat<=e.north&&t.lat>=e.south&&t.lng>=e.west&&t.lng<=e.east}};export{o as FakeMapProvider,a as InMemoryEntityAdapter};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-listing-engine",
3
- "version": "0.6.9",
3
+ "version": "0.7.0",
4
4
  "license": "MIT",
5
5
  "description": "Headless, composable listing engine for React: filterable list + Google-Maps multi-layer map, with pluggable data adapters, a filter/dataset registry, injectable components, and a Tailwind-free styled adapter.",
6
6
  "funding": [
@@ -1,2 +0,0 @@
1
- "use client";
2
- var H=class{state;listeners=new Set;constructor(e){this.state=this.freezeState({filters:{...e.filters},results:{items:[],nextCursor:null},bounds:null,selection:null,pagination:{mode:e.mode??"paged",loading:!1},layers:{},points:{}})}getState(){return this.state}setFilters(e){this.setState({filters:{...this.state.filters,...e}})}setResults(e){this.setState({results:{items:[...e.items],nextCursor:e.nextCursor,total:e.total}})}appendResults(e){this.setState({results:{items:[...this.state.results.items,...e.items],nextCursor:e.nextCursor,total:e.total}})}setBounds(e){this.setState({bounds:e?{...e}:null})}setSelection(e){this.setState({selection:e})}setLayerVisible(e,i){this.setState({layers:{...this.state.layers,[e]:i}})}setLoading(e){this.setState({pagination:{...this.state.pagination,loading:e}})}setPoints(e,i){this.setState({points:{...this.state.points,[e]:[...i]}})}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setState(e){this.state=this.freezeState({...this.state,...e}),this.notify()}notify(){for(let e of this.listeners)e()}freezeState(e){Object.freeze(e.filters),Object.freeze(e.results.items),Object.freeze(e.results),e.bounds&&Object.freeze(e.bounds),Object.freeze(e.pagination),Object.freeze(e.layers);for(let i of Object.values(e.points))Object.freeze(i);return Object.freeze(e.points),Object.freeze(e)}};var N=class{defs=new Map;add(e){if(this.defs.has(e.key))throw new Error(`FilterRegistry: filter "${e.key}" is already registered`);return this.defs.set(e.key,{...e}),this}remove(e){return this.defs.delete(e),this}replace(e,i){if(!this.defs.has(e))throw new Error(`FilterRegistry: cannot replace unregistered filter "${e}"`);return this.defs.set(e,{...i,key:e}),this}reorder(e){let i=this.list(),r=e.filter(s=>this.defs.has(s));r.forEach((s,o)=>{this.defs.get(s).order=o});let n=new Set(r);return i.filter(s=>!n.has(s.key)).forEach((s,o)=>{s.order=r.length+o}),this}list(){return[...this.defs.values()].sort((e,i)=>e.order-i.order)}has(e){return this.defs.has(e)}toFilters(e){return this.list().filter(r=>Object.hasOwn(e,r.key)).map(r=>r.toParams(e[r.key])).reduce((r,n)=>({...r,...n}),{})}activeKeys(e){return this.list().filter(i=>i.isActive?.(e)).map(i=>i.key)}clearedParams(){return this.list().reduce((e,i)=>Object.assign(e,i.toParams(i.fromParams({}))),{})}};var z=class{defs=new Map;add(e){if(this.defs.has(e.id))throw new Error(`DatasetRegistry: dataset "${e.id}" is already registered`);return this.defs.set(e.id,{...e}),this}get(e){return this.defs.get(e)}has(e){return this.defs.has(e)}list(){return[...this.defs.values()]}visibleIds(){return this.list().filter(e=>e.visible?.()!==!1).map(e=>e.id)}};var U=class{map=new Map;dispose(){this.map.clear()}emit(e){let i=this.map.get(e.type);if(i)for(let n of[...i])n(e);let r=this.map.get("*");if(r)for(let n of[...r])n(e)}on(e,i){let r=this.map.get(e);return r||(r=new Set,this.map.set(e,r)),r.add(i),()=>{r.delete(i)}}};var ge={pagination:"paged",pageSize:20,debounceMs:250};var V=class{options;constructor(e){this.options=Object.freeze({...ge,...e})}};var K=class{filters;map;datasets;primaryDatasetId;store;emitter=new U;config;debounceTimer=null;debounceResolve=null;queryToken=0;pointsToken=0;constructor(e){this.datasets=e.datasets,this.filters=e.filters??new N,this.map=e.map,this.config=new V(e.config);let i=e.primaryDatasetId??this.datasets.list()[0]?.id;if(i==null||!this.datasets.has(i))throw new Error(`ListingEngine: primary dataset "${i??""}" is not registered \u2014 pass a valid primaryDatasetId or register at least one dataset`);this.primaryDatasetId=i,this.store=new H({filters:e.initialFilters??{},mode:this.config.options.pagination})}get state(){return this.store.getState()}get options(){return this.config.options}applyFilters(e){this.store.setFilters(e),this.emitter.emit({type:"FiltersChanged",filters:this.currentFilters()}),this.clearDebounce();let i=++this.queryToken,r=this.config.options.debounceMs;return r<=0?this.runQuery(i):new Promise(n=>{this.debounceResolve=n,this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.debounceResolve=null,n(this.runQuery(i))},r)})}async loadPage(){let e=this.state.results.nextCursor;if(e===null)return;let i=++this.queryToken,r=this.primaryDataset();this.store.setLoading(!0);try{let n=await r.adapter.list(this.currentFilters(),{cursor:e,limit:this.config.options.pageSize});if(i!==this.queryToken)return;this.config.options.pagination==="infinite"?this.store.appendResults(n):this.store.setResults(n),this.emitter.emit({type:"ResultsLoaded",datasetId:this.primaryDatasetId,count:n.items.length})}finally{i===this.queryToken&&this.store.setLoading(!1)}}async loadPoints(e){this.store.setBounds(e),this.emitter.emit({type:"BoundsChanged",bounds:e});let i=this.currentFilters(),r=++this.pointsToken;await Promise.allSettled(this.datasets.visibleIds().map(async n=>{let s=this.datasets.get(n);if(!s)return;let o=await s.adapter.getPoints(i,e);r===this.pointsToken&&this.store.setPoints(n,o)}))}selectPoint(e,i){this.store.setSelection(i);let r=this.state.points[e]?.find(n=>n.id===i);r&&this.emitter.emit({type:"PointClicked",datasetId:e,id:i,entity:r.entity})}toggleLayer(e){let r=!(this.state.layers[e]??!0);this.store.setLayerVisible(e,r),this.emitter.emit({type:"LayerToggled",datasetId:e,visible:r})}subscribe(e){return this.store.subscribe(e)}on(e,i){return this.emitter.on(e,i)}dispose(){this.clearDebounce(),this.emitter.dispose()}async runQuery(e){if(e!==this.queryToken)return;let i=this.primaryDataset();this.store.setLoading(!0);try{let r=await i.adapter.list(this.currentFilters(),{cursor:null,limit:this.config.options.pageSize});if(e!==this.queryToken)return;this.store.setResults(r),this.emitter.emit({type:"ResultsLoaded",datasetId:this.primaryDatasetId,count:r.items.length})}finally{e===this.queryToken&&this.store.setLoading(!1)}}primaryDataset(){return this.datasets.get(this.primaryDatasetId)}currentFilters(){return this.store.getState().filters}clearDebounce(){this.debounceTimer!==null&&(clearTimeout(this.debounceTimer),this.debounceTimer=null),this.debounceResolve!==null&&(this.debounceResolve(),this.debounceResolve=null)}};function fe(...t){let e={config:{},filters:new N,datasets:new z};for(let i of t)i(e);return e}var ye=t=>e=>{e.config={...e.config,...t}},he=t=>e=>{e.map=t},ve=t=>e=>{e.datasets.add(t)},Le=t=>e=>{t(e.filters)},pi=t=>e=>{e.urlSync=t},be=t=>e=>{e.initialFilters=t},ci=t=>e=>{e.primaryDatasetId=t};import{createContext as Qe,useContext as Ge}from"react";import{jsx as C,jsxs as at}from"react/jsx-runtime";function Ze(t){return String(t?.title??"")}var Xe=({item:t})=>C("div",{children:Ze(t)}),Je=()=>C("div",{}),Ye=()=>C("div",{}),et=({children:t})=>C("div",{children:t}),tt=({children:t})=>C("div",{children:t}),it=({value:t,onChange:e,placeholder:i})=>C("input",{type:"search",value:t,placeholder:i,onChange:r=>e(r.target.value),"aria-label":i??"Search"}),rt=()=>C("div",{role:"status",children:"No results"}),nt=()=>C("div",{role:"status","aria-busy":"true",children:"Loading\u2026"}),st=({count:t})=>at("div",{children:[t," results"]}),ot=({children:t})=>C("div",{children:t}),P={Card:Xe,Marker:Je,Popup:Ye,Sidebar:et,FilterPanel:tt,Search:it,Empty:rt,Loading:nt,ResultHeader:st,Toolbar:ot},Te=Qe(P);function Pe(t){let{Card:e,Marker:i,Popup:r,Sidebar:n,FilterPanel:s,Search:o,Empty:a,Loading:l,ResultHeader:c,Toolbar:d,children:v}=t,L={Card:e??P.Card,Marker:i??P.Marker,Popup:r??P.Popup,Sidebar:n??P.Sidebar,FilterPanel:s??P.FilterPanel,Search:o??P.Search,Empty:a??P.Empty,Loading:l??P.Loading,ResultHeader:c??P.ResultHeader,Toolbar:d??P.Toolbar};return C(Te.Provider,{value:L,children:v})}function F(){return Ge(Te)}import{createContext as lt}from"react";var $=lt(null);import{useContext as dt}from"react";function y(){let t=dt($);if(t===null)throw new Error("useListing must be used within a <ListingProvider>");return t}import{useCallback as Fe,useSyncExternalStore as pt}from"react";function S(){let t=y(),e=Fe(r=>t.subscribe(r),[t]),i=Fe(()=>t.state,[t]);return pt(e,i,i)}import{useCallback as Ce}from"react";function W(){let t=y(),e=S(),i=Ce(n=>t.applyFilters(n),[t]),r=Ce((n,s)=>t.applyFilters({[n]:s}),[t]);return{filters:e.filters,set:i,setField:r}}import{jsx as _,jsxs as ct}from"react/jsx-runtime";function Y({className:t,groupClassName:e,hideLabels:i}={}){let r=y(),{FilterPanel:n}=F(),{filters:s}=W();return _(n,{children:_("div",{className:t??"space-y-5",children:r.filters.list().map(o=>{if(typeof o.render=="string")return _("div",{"data-filter":o.key,className:e},o.key);let a=o.render;return ct("div",{className:e,children:[o.label&&!i&&_("div",{className:"mb-1.5 text-[13px] font-medium text-foreground",children:o.label}),_(a,{value:o.fromParams(s),onChange:l=>{r.applyFilters(o.toParams(l))}})]},o.key)})})})}function R(){return S().results}import{jsx as q}from"react/jsx-runtime";function ut(t,e){if(t&&typeof t=="object"&&"id"in t){let i=t.id;if(typeof i=="string"||typeof i=="number")return i}return e}function Se({className:t}={}){let e=y(),{items:i}=R(),{pagination:r,selection:n}=S(),{Card:s,Empty:o,Loading:a}=F();return r.loading&&i.length===0?q(a,{}):i.length===0?q(o,{}):q("div",{role:"list",className:t,children:i.map((l,c)=>{let d=ut(l,c);return q(s,{item:l,selected:n===d,onSelect:()=>e.selectPoint(e.primaryDatasetId,d)},d)})})}import{useEffect as ee,useRef as B,useState as mt}from"react";import{jsx as yt}from"react/jsx-runtime";var gt={west:-179.9,south:-85,east:179.9,north:85},Ie=.1,we=.02;function ft(t){if(t.length===0)return null;let e=t[0].lng,i=t[0].lng,r=t[0].lat,n=t[0].lat;for(let{lat:a,lng:l}of t)l<e&&(e=l),l>i&&(i=l),a<r&&(r=a),a>n&&(n=a);let s=n>r?(n-r)*Ie:we,o=i>e?(i-e)*Ie:we;return{west:e-o,east:i+o,south:r-s,north:n+s}}function ke(t){let{center:e,zoom:i,fallback:r}=t,n=y(),s=S(),o=B(null),a=B(null),[l,c]=mt(!1),d=B(!1),v=B(!1),L=B(!1),p=n.map;return ee(()=>{let b=a.current;if(!p||!b)return;let u=[];for(let m of Object.keys(s.points)){if(s.layers[m]===!1)continue;let f=n.datasets.get(m),I=s.points[m]??[],J={id:m,markers:I.map(E=>({id:E.id,position:E.position,iconUrl:f?.marker.iconUrl?.(E.entity),element:f?.marker.element?.(E.entity)})),clustering:f?.clustering,onMarkerClick:E=>n.selectPoint(m,E)};u.push(p.renderLayer(b,J))}return()=>{u.forEach(m=>m())}},[n,p,l,s.points,s.layers]),ee(()=>{if(!o.current||!p)return;let b=o.current,u=!1,m=null;return(async()=>{let f=await p.mount(b,{center:e,zoom:i});if(u){p.destroy(f);return}a.current=f,m=p.onBoundsChange(f,I=>{L.current?L.current=!1:v.current=!0,n.loadPoints(I)}),c(!0),n.loadPoints(gt)})(),()=>{u=!0,m?.(),a.current&&(p.destroy(a.current),a.current=null),c(!1)}},[n,p]),ee(()=>{let b=a.current;if(!p||!b||e||d.current||v.current)return;let u=[];for(let f of Object.keys(s.points))if(s.layers[f]!==!1)for(let I of s.points[f]??[])u.push(I.position);let m=ft(u);m&&(d.current=!0,L.current=!0,p.fitBounds(b,m))},[p,e,l,s.points,s.layers]),yt("div",{ref:o,className:!p&&r?"flex h-full min-h-0 w-full items-center justify-center":"h-full min-h-0 w-full",children:!p&&r})}import{jsx as ht}from"react/jsx-runtime";function Ee(){let t=y(),{results:e,pagination:i}=S();return e.nextCursor==null?null:ht("button",{type:"button",disabled:i.loading,onClick:()=>{t.loadPage()},children:"Load more"})}import{jsx as vt}from"react/jsx-runtime";function xe(){let{items:t,total:e}=R(),{ResultHeader:i}=F();return vt(i,{count:t.length,total:e})}import{useEffect as Lt,useRef as bt}from"react";function Ne(t,e){let i=y(),r=bt(e);r.current=e,Lt(()=>i.on(t,n=>r.current(n)),[i,t])}import{useEffect as Tt,useState as Re}from"react";import{jsx as Pt}from"react/jsx-runtime";function Me(t){let{children:e,...i}=t,[r]=Re(()=>i),[n,s]=Re(null);return Tt(()=>{let o=new K({datasets:r.datasets,filters:r.filters,config:r.config,map:r.map,initialFilters:r.initialFilters,primaryDatasetId:r.primaryDatasetId});return r.urlSync&&r.urlSync.start(o),s(o),()=>{r.urlSync&&r.urlSync.stop(),o.dispose(),s(a=>a===o?null:a)}},[r]),n?Pt($.Provider,{value:n,children:e}):null}function M(t){return typeof t!="number"?t:new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t)}import{Fragment as Ct,jsx as w,jsxs as De}from"react/jsx-runtime";function Ft(t){return t?"rle-card rle-card--selected":"rle-card"}function te({item:t,selected:e,onSelect:i}){let r=t??{},n=Ft(e),s=De(Ct,{children:[r.imageUrl?w("img",{src:r.imageUrl,alt:r.title??"",className:"rle-card-media"}):w("div",{className:"rle-card-media rle-card-media--placeholder","aria-hidden":"true"}),De("div",{className:"rle-card-body",children:[r.title&&w("span",{className:"rle-card-title",children:r.title}),r.subtitle&&w("span",{className:"rle-card-address",children:r.subtitle}),r.badge&&w("div",{className:"rle-card-info",children:w("span",{className:"rle-card-info-item",children:r.badge})}),r.price!=null&&w("span",{className:"rle-card-price",children:M(r.price)})]})]});return i?w("button",{type:"button",onClick:i,"aria-pressed":e??!1,className:n,children:s}):w("article",{className:n,children:s})}import{jsx as j,jsxs as Oe}from"react/jsx-runtime";function ie(t){return Oe("div",{role:"status",className:"rle-empty",children:[Oe("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",className:"rle-empty-icon","aria-hidden":"true",children:[j("circle",{cx:"11",cy:"11",r:"7"}),j("path",{d:"m21 21-4.3-4.3"})]}),j("p",{className:"rle-empty-title",children:"No results"}),j("p",{className:"rle-empty-hint",children:"Try adjusting your filters or search terms."})]})}import{jsx as St}from"react/jsx-runtime";function re({children:t}){return St("div",{className:"rle-filter-panel",children:t})}import{jsx as Q,jsxs as It}from"react/jsx-runtime";function ne(t){return Q("div",{className:"rle-loading",role:"status","aria-busy":"true","aria-label":"Loading results",children:Array.from({length:3}).map((e,i)=>It("div",{className:"rle-loading-item",children:[Q("div",{className:"rle-skeleton",style:{aspectRatio:"4 / 3",width:"100%"}}),Q("div",{className:"rle-skeleton",style:{height:16,width:"65%"}}),Q("div",{className:"rle-skeleton",style:{height:12,width:"35%"}})]},i))})}import{jsx as wt}from"react/jsx-runtime";function se({point:t}){let e=t.entity??{};return wt("span",{className:"rle-pin",children:e.price!=null?M(e.price):""})}import{jsx as D,jsxs as oe}from"react/jsx-runtime";function ae({entity:t,onClose:e}){let i=t??{};return oe("div",{className:"rle-popup",role:"group","aria-label":"Location details",children:[D("button",{type:"button",onClick:e,"aria-label":"Close",className:"rle-popup-close",children:oe("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"16",height:"16","aria-hidden":"true",children:[D("path",{d:"M18 6 6 18"}),D("path",{d:"m6 6 12 12"})]})}),oe("div",{children:[i.title&&D("div",{className:"rle-card-title",children:i.title}),i.subtitle&&D("div",{className:"rle-card-address",children:i.subtitle}),i.price!=null&&D("div",{className:"rle-card-price",children:M(i.price)})]})]})}import{jsx as kt}from"react/jsx-runtime";function le({count:t,total:e}){let i=e!=null&&e!==t?`${t} of ${e} results`:`${t} results`;return kt("div",{className:"rle-result-header",children:i})}import{jsx as Et}from"react/jsx-runtime";function de({value:t,onChange:e,placeholder:i}){return Et("input",{type:"search",value:t,placeholder:i,onChange:r=>e(r.target.value),"aria-label":i??"Search",className:"rle-input"})}import{jsx as xt}from"react/jsx-runtime";function pe({children:t}){return xt("aside",{className:"rle-sidebar",children:t})}import{jsx as Nt}from"react/jsx-runtime";function ce({children:t}){return Nt("div",{className:"rle-toolbar",children:t})}var _e={Card:te,Marker:se,Popup:ae,Sidebar:pe,FilterPanel:re,Search:de,Empty:ie,Loading:ne,ResultHeader:le,Toolbar:ce};import{jsx as T,jsxs as A}from"react/jsx-runtime";function Be({view:t,onViewChange:e}){return T("nav",{className:"rle-bottom-nav","aria-label":"Listing navigation",children:A("div",{className:"rle-viewtoggle",role:"group","aria-label":"View",children:[A("button",{type:"button",className:`rle-viewtoggle__btn${t==="list"?" rle-viewtoggle__btn--active":""}`,"aria-pressed":t==="list",onClick:()=>e("list"),children:[T(Rt,{}),"List"]}),A("button",{type:"button",className:`rle-viewtoggle__btn${t==="map"?" rle-viewtoggle__btn--active":""}`,"aria-pressed":t==="map",onClick:()=>e("map"),children:[T(Mt,{}),"Map"]})]})})}function Rt(){return A("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"16",height:"16","aria-hidden":"true",children:[T("line",{x1:"8",y1:"6",x2:"20",y2:"6"}),T("line",{x1:"8",y1:"12",x2:"20",y2:"12"}),T("line",{x1:"8",y1:"18",x2:"20",y2:"18"}),T("line",{x1:"4",y1:"6",x2:"4.01",y2:"6"}),T("line",{x1:"4",y1:"12",x2:"4.01",y2:"12"}),T("line",{x1:"4",y1:"18",x2:"4.01",y2:"18"})]})}function Mt(){return A("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"16",height:"16","aria-hidden":"true",children:[T("polygon",{points:"1 6 8 3 16 6 23 3 23 18 16 21 8 18 1 21 1 6"}),T("line",{x1:"8",y1:"3",x2:"8",y2:"18"}),T("line",{x1:"16",y1:"6",x2:"16",y2:"21"})]})}import{useEffect as ue,useRef as Dt,useState as Ae}from"react";import{createPortal as Ot}from"react-dom";import{Fragment as Bt,jsx as k,jsxs as G}from"react/jsx-runtime";function He({open:t,onOpenChange:e,title:i,children:r,footer:n}){let s=Dt(null),[o,a]=Ae(!1),[l,c]=Ae(!1);return ue(()=>{if(!t){c(!1),a(!1);return}a(!0);let d=requestAnimationFrame(()=>c(!0));return()=>cancelAnimationFrame(d)},[t]),ue(()=>{if(!o)return;let d=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=d}},[o]),ue(()=>{if(!o)return;s.current?.focus();function d(v){v.key==="Escape"&&e(!1)}return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[o,e]),!o||typeof document>"u"?null:Ot(G(Bt,{children:[k("div",{className:`rle-sheet-backdrop${l?" rle-sheet-backdrop--open":""}`,onClick:()=>e(!1),"aria-hidden":"true"}),G("div",{ref:s,className:`rle-sheet${l?" rle-sheet--open":""}`,role:"dialog","aria-modal":"true","aria-label":i,tabIndex:-1,children:[k("div",{className:"rle-sheet__handle","aria-hidden":"true"}),G("div",{className:"rle-sheet__header",children:[i&&k("div",{className:"rle-sheet__title",children:i}),k("button",{type:"button",className:"rle-sheet__close",onClick:()=>e(!1),"aria-label":"Close",children:k(_t,{})})]}),k("div",{className:"rle-sheet__body",children:r}),n&&k("div",{className:"rle-sheet__footer",children:n})]})]}),document.body)}function _t(){return G("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"16",height:"16","aria-hidden":"true",children:[k("path",{d:"M18 6 6 18"}),k("path",{d:"m6 6 12 12"})]})}import{useEffect as Ue,useRef as zt,useState as X}from"react";import{jsx as h,jsxs as Z}from"react/jsx-runtime";function ze({search:t,onFiltersClick:e,filterCount:i=0,action:r}){let{Search:n}=F();return Z("header",{className:"rle-mobile-header",children:[t&&h("div",{className:"rle-mobile-header__search",children:h(n,{value:t.value,onChange:t.onChange,placeholder:t.placeholder})}),Z("button",{type:"button",className:"rle-btn rle-mobile-header__btn",onClick:e,children:[h(At,{}),h("span",{children:"Filters"}),i>0&&h("span",{className:"rle-mobile-header__count",children:i})]}),r&&h("button",{type:"button",className:"rle-btn rle-mobile-header__btn rle-mobile-header__btn--icon",onClick:r.onClick,"aria-label":r.label,children:r.icon??h(Ht,{})})]})}function At(){return Z("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[h("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),h("circle",{cx:"9",cy:"6",r:"2",fill:"currentColor",stroke:"none"}),h("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),h("circle",{cx:"15",cy:"12",r:"2",fill:"currentColor",stroke:"none"}),h("line",{x1:"4",y1:"18",x2:"20",y2:"18"}),h("circle",{cx:"11",cy:"18",r:"2",fill:"currentColor",stroke:"none"})]})}function Ht(){return Z("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[h("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),h("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}import{Fragment as Kt,jsx as g,jsxs as x}from"react/jsx-runtime";var Ut=g("div",{className:"rle-empty",children:"Map unavailable"});function Vt(){let t=zt(null),[e,i]=X(!0),[r,n]=X(!0);return Ue(()=>{let s=t.current;if(!s)return;let o=()=>{let{clientWidth:v,scrollLeft:L,scrollWidth:p}=s;i(L<=0),n(L+v>=p-1)},a=0,l=()=>{a||(a=requestAnimationFrame(()=>{a=0,o()}))};o(),s.addEventListener("scroll",o,{passive:!0});let c,d;return typeof ResizeObserver<"u"&&(c=new ResizeObserver(o),c.observe(s)),typeof MutationObserver<"u"&&(d=new MutationObserver(l),d.observe(s,{characterData:!0,childList:!0,subtree:!0})),()=>{s.removeEventListener("scroll",o),c?.disconnect(),d?.disconnect(),a&&cancelAnimationFrame(a)}},[]),{atEnd:r,atStart:e,ref:t}}function Ve({search:t,toolbarEnd:e,mobileAction:i,autoFetch:r=!0,hasMap:n,mapCenter:s,mapZoom:o,className:a}){let l=y(),{Search:c}=F(),d=R(),{filters:v,set:L}=W(),p=n??l.map!=null,[b,u]=X("list"),[m,f]=X(!1),{atEnd:I,atStart:J,ref:E}=Vt(),O=t?{value:String(v[t.filterKey]??""),onChange:je=>{L({[t.filterKey]:je||void 0})},placeholder:t.placeholder}:void 0;Ue(()=>{r!==!1&&l.applyFilters({})},[l,r]);let $e=()=>{L(l.filters.clearedParams())},We=l.filters.activeKeys(v).length,qe=d.total??d.items.length;return x("div",{className:a?`rle-app ${a}`:"rle-app",children:[x("div",{className:"rle-filter-bar",children:[x("div",{className:"rle-filter-bar__scroll",ref:E,children:[O&&g("div",{className:"rle-filter-bar__search",children:g(c,{value:O.value,onChange:O.onChange,placeholder:O.placeholder})}),g(Y,{className:"rle-filters-row",groupClassName:"rle-filter-group",hideLabels:!0})]}),!J&&g("div",{className:"rle-filter-bar__fade rle-filter-bar__fade--start","aria-hidden":"true"}),!I&&g("div",{className:"rle-filter-bar__fade rle-filter-bar__fade--end","aria-hidden":"true"})]}),g(ze,{search:O,onFiltersClick:()=>f(!0),filterCount:We,action:i}),x("div",{className:`rle-body ${p?"rle-split":"rle-body--list-only"}`,"data-mobile-view":b,children:[x("div",{className:"rle-list",children:[x("div",{className:"rle-list-header",children:[g(xe,{}),e&&g("div",{className:"rle-list-header__toolbar",children:e})]}),g(Se,{className:"rle-list-grid"}),g(Ee,{})]}),p&&g("div",{className:"rle-map",children:g(ke,{center:s,zoom:o,fallback:Ut})})]}),p&&g(Be,{view:b,onViewChange:u}),g(He,{title:"Filters",open:m,onOpenChange:f,footer:x(Kt,{children:[g("button",{type:"button",className:"rle-btn rle-btn--ghost",onClick:$e,children:"Clear all"}),x("button",{type:"button",className:"rle-btn rle-btn--primary",onClick:()=>f(!1),children:["Show ",qe," results"]})]}),children:g(Y,{className:"rle-filter-stack",groupClassName:"rle-filter-group"})})]})}import{useEffect as $t,useRef as Wt,useState as qt}from"react";import{jsx as me,jsxs as Gt}from"react/jsx-runtime";function Ke(t){return"provider"in t}function jt(t){let e=t!=null&&!Ke(t),i=e?t.apiKey:void 0,r=e?t.mapId:void 0,n=e?t.mapOptions:void 0,s=e?t.styles:void 0,[o,a]=qt(()=>!t||Ke(t)?{ready:!0,provider:t?.provider}:{ready:!1});return $t(()=>{if(!i)return;let l=!1;return import("./maps/google/index.js").then(({googleProvider:c})=>{l||a({ready:!0,provider:c({apiKey:i,mapId:r,mapOptions:n,styles:s})})}),()=>{l=!0}},[i,r]),o}function Qt({onFiltersChange:t}){let e=Wt(t);return e.current=t,Ne("FiltersChanged",i=>{i.type==="FiltersChanged"&&e.current(i.filters)}),null}function mn(t){let{datasets:e,filters:i,map:r,components:n,initialFilters:s,onFiltersChange:o,mobileAction:a,search:l,toolbarEnd:c,config:d,autoFetch:v,className:L}=t,{ready:p,provider:b}=jt(r);if(!p)return null;let u=[];for(let I of e)u.push(ve(I));i&&u.push(Le(i)),b&&u.push(he(b)),s&&u.push(be(s)),d&&u.push(ye(d));let m=fe(...u),f={..._e,...n};return Gt(Me,{...m,children:[o&&me(Qt,{onFiltersChange:o}),me(Pe,{...f,children:me(Ve,{className:L,search:l,toolbarEnd:c,mobileAction:a,autoFetch:v,mapCenter:r?.center,mapZoom:r?.zoom})})]})}export{H as a,N as b,z as c,U as d,ge as e,V as f,K as g,fe as h,ye as i,he as j,ve as k,Le as l,pi as m,be as n,ci as o,Pe as p,F as q,$ as r,y as s,S as t,W as u,Y as v,R as w,Se as x,ke as y,Ee as z,xe as A,Ne as B,Me as C,te as D,ie as E,re as F,ne as G,se as H,ae as I,le as J,de as K,pe as L,ce as M,_e as N,Be as O,He as P,Ve as Q,mn as R};
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5;"use client";
2
- var H= (_class =class{__init() {this.listeners=new Set}constructor(e){;_class.prototype.__init.call(this);this.state=this.freezeState({filters:{...e.filters},results:{items:[],nextCursor:null},bounds:null,selection:null,pagination:{mode:_nullishCoalesce(e.mode, () => ("paged")),loading:!1},layers:{},points:{}})}getState(){return this.state}setFilters(e){this.setState({filters:{...this.state.filters,...e}})}setResults(e){this.setState({results:{items:[...e.items],nextCursor:e.nextCursor,total:e.total}})}appendResults(e){this.setState({results:{items:[...this.state.results.items,...e.items],nextCursor:e.nextCursor,total:e.total}})}setBounds(e){this.setState({bounds:e?{...e}:null})}setSelection(e){this.setState({selection:e})}setLayerVisible(e,i){this.setState({layers:{...this.state.layers,[e]:i}})}setLoading(e){this.setState({pagination:{...this.state.pagination,loading:e}})}setPoints(e,i){this.setState({points:{...this.state.points,[e]:[...i]}})}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setState(e){this.state=this.freezeState({...this.state,...e}),this.notify()}notify(){for(let e of this.listeners)e()}freezeState(e){Object.freeze(e.filters),Object.freeze(e.results.items),Object.freeze(e.results),e.bounds&&Object.freeze(e.bounds),Object.freeze(e.pagination),Object.freeze(e.layers);for(let i of Object.values(e.points))Object.freeze(i);return Object.freeze(e.points),Object.freeze(e)}}, _class);var N= (_class2 =class{constructor() { _class2.prototype.__init2.call(this); }__init2() {this.defs=new Map}add(e){if(this.defs.has(e.key))throw new Error(`FilterRegistry: filter "${e.key}" is already registered`);return this.defs.set(e.key,{...e}),this}remove(e){return this.defs.delete(e),this}replace(e,i){if(!this.defs.has(e))throw new Error(`FilterRegistry: cannot replace unregistered filter "${e}"`);return this.defs.set(e,{...i,key:e}),this}reorder(e){let i=this.list(),r=e.filter(s=>this.defs.has(s));r.forEach((s,o)=>{this.defs.get(s).order=o});let n=new Set(r);return i.filter(s=>!n.has(s.key)).forEach((s,o)=>{s.order=r.length+o}),this}list(){return[...this.defs.values()].sort((e,i)=>e.order-i.order)}has(e){return this.defs.has(e)}toFilters(e){return this.list().filter(r=>Object.hasOwn(e,r.key)).map(r=>r.toParams(e[r.key])).reduce((r,n)=>({...r,...n}),{})}activeKeys(e){return this.list().filter(i=>_optionalChain([i, 'access', _2 => _2.isActive, 'optionalCall', _3 => _3(e)])).map(i=>i.key)}clearedParams(){return this.list().reduce((e,i)=>Object.assign(e,i.toParams(i.fromParams({}))),{})}}, _class2);var z= (_class3 =class{constructor() { _class3.prototype.__init3.call(this); }__init3() {this.defs=new Map}add(e){if(this.defs.has(e.id))throw new Error(`DatasetRegistry: dataset "${e.id}" is already registered`);return this.defs.set(e.id,{...e}),this}get(e){return this.defs.get(e)}has(e){return this.defs.has(e)}list(){return[...this.defs.values()]}visibleIds(){return this.list().filter(e=>_optionalChain([e, 'access', _4 => _4.visible, 'optionalCall', _5 => _5()])!==!1).map(e=>e.id)}}, _class3);var U= (_class4 =class{constructor() { _class4.prototype.__init4.call(this); }__init4() {this.map=new Map}dispose(){this.map.clear()}emit(e){let i=this.map.get(e.type);if(i)for(let n of[...i])n(e);let r=this.map.get("*");if(r)for(let n of[...r])n(e)}on(e,i){let r=this.map.get(e);return r||(r=new Set,this.map.set(e,r)),r.add(i),()=>{r.delete(i)}}}, _class4);var ge={pagination:"paged",pageSize:20,debounceMs:250};var V=class{constructor(e){this.options=Object.freeze({...ge,...e})}};var K= (_class5 =class{__init5() {this.emitter=new U}__init6() {this.debounceTimer=null}__init7() {this.debounceResolve=null}__init8() {this.queryToken=0}__init9() {this.pointsToken=0}constructor(e){;_class5.prototype.__init5.call(this);_class5.prototype.__init6.call(this);_class5.prototype.__init7.call(this);_class5.prototype.__init8.call(this);_class5.prototype.__init9.call(this);this.datasets=e.datasets,this.filters=_nullishCoalesce(e.filters, () => (new N)),this.map=e.map,this.config=new V(e.config);let i=_nullishCoalesce(e.primaryDatasetId, () => (_optionalChain([this, 'access', _6 => _6.datasets, 'access', _7 => _7.list, 'call', _8 => _8(), 'access', _9 => _9[0], 'optionalAccess', _10 => _10.id])));if(i==null||!this.datasets.has(i))throw new Error(`ListingEngine: primary dataset "${_nullishCoalesce(i, () => (""))}" is not registered \u2014 pass a valid primaryDatasetId or register at least one dataset`);this.primaryDatasetId=i,this.store=new H({filters:_nullishCoalesce(e.initialFilters, () => ({})),mode:this.config.options.pagination})}get state(){return this.store.getState()}get options(){return this.config.options}applyFilters(e){this.store.setFilters(e),this.emitter.emit({type:"FiltersChanged",filters:this.currentFilters()}),this.clearDebounce();let i=++this.queryToken,r=this.config.options.debounceMs;return r<=0?this.runQuery(i):new Promise(n=>{this.debounceResolve=n,this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.debounceResolve=null,n(this.runQuery(i))},r)})}async loadPage(){let e=this.state.results.nextCursor;if(e===null)return;let i=++this.queryToken,r=this.primaryDataset();this.store.setLoading(!0);try{let n=await r.adapter.list(this.currentFilters(),{cursor:e,limit:this.config.options.pageSize});if(i!==this.queryToken)return;this.config.options.pagination==="infinite"?this.store.appendResults(n):this.store.setResults(n),this.emitter.emit({type:"ResultsLoaded",datasetId:this.primaryDatasetId,count:n.items.length})}finally{i===this.queryToken&&this.store.setLoading(!1)}}async loadPoints(e){this.store.setBounds(e),this.emitter.emit({type:"BoundsChanged",bounds:e});let i=this.currentFilters(),r=++this.pointsToken;await Promise.allSettled(this.datasets.visibleIds().map(async n=>{let s=this.datasets.get(n);if(!s)return;let o=await s.adapter.getPoints(i,e);r===this.pointsToken&&this.store.setPoints(n,o)}))}selectPoint(e,i){this.store.setSelection(i);let r=_optionalChain([this, 'access', _11 => _11.state, 'access', _12 => _12.points, 'access', _13 => _13[e], 'optionalAccess', _14 => _14.find, 'call', _15 => _15(n=>n.id===i)]);r&&this.emitter.emit({type:"PointClicked",datasetId:e,id:i,entity:r.entity})}toggleLayer(e){let r=!(_nullishCoalesce(this.state.layers[e], () => (!0)));this.store.setLayerVisible(e,r),this.emitter.emit({type:"LayerToggled",datasetId:e,visible:r})}subscribe(e){return this.store.subscribe(e)}on(e,i){return this.emitter.on(e,i)}dispose(){this.clearDebounce(),this.emitter.dispose()}async runQuery(e){if(e!==this.queryToken)return;let i=this.primaryDataset();this.store.setLoading(!0);try{let r=await i.adapter.list(this.currentFilters(),{cursor:null,limit:this.config.options.pageSize});if(e!==this.queryToken)return;this.store.setResults(r),this.emitter.emit({type:"ResultsLoaded",datasetId:this.primaryDatasetId,count:r.items.length})}finally{e===this.queryToken&&this.store.setLoading(!1)}}primaryDataset(){return this.datasets.get(this.primaryDatasetId)}currentFilters(){return this.store.getState().filters}clearDebounce(){this.debounceTimer!==null&&(clearTimeout(this.debounceTimer),this.debounceTimer=null),this.debounceResolve!==null&&(this.debounceResolve(),this.debounceResolve=null)}}, _class5);function fe(...t){let e={config:{},filters:new N,datasets:new z};for(let i of t)i(e);return e}var ye=t=>e=>{e.config={...e.config,...t}},he= exports.j =t=>e=>{e.map=t},ve= exports.k =t=>e=>{e.datasets.add(t)},Le= exports.l =t=>e=>{t(e.filters)},pi= exports.m =t=>e=>{e.urlSync=t},be= exports.n =t=>e=>{e.initialFilters=t},ci= exports.o =t=>e=>{e.primaryDatasetId=t};var _react = require('react');var _jsxruntime = require('react/jsx-runtime');function Ze(t){return String(_nullishCoalesce(_optionalChain([t, 'optionalAccess', _16 => _16.title]), () => ("")))}var Xe=({item:t})=>_jsxruntime.jsx.call(void 0, "div",{children:Ze(t)}),Je=()=>_jsxruntime.jsx.call(void 0, "div",{}),Ye=()=>_jsxruntime.jsx.call(void 0, "div",{}),et=({children:t})=>_jsxruntime.jsx.call(void 0, "div",{children:t}),tt=({children:t})=>_jsxruntime.jsx.call(void 0, "div",{children:t}),it=({value:t,onChange:e,placeholder:i})=>_jsxruntime.jsx.call(void 0, "input",{type:"search",value:t,placeholder:i,onChange:r=>e(r.target.value),"aria-label":_nullishCoalesce(i, () => ("Search"))}),rt=()=>_jsxruntime.jsx.call(void 0, "div",{role:"status",children:"No results"}),nt=()=>_jsxruntime.jsx.call(void 0, "div",{role:"status","aria-busy":"true",children:"Loading\u2026"}),st=({count:t})=>_jsxruntime.jsxs.call(void 0, "div",{children:[t," results"]}),ot=({children:t})=>_jsxruntime.jsx.call(void 0, "div",{children:t}),P={Card:Xe,Marker:Je,Popup:Ye,Sidebar:et,FilterPanel:tt,Search:it,Empty:rt,Loading:nt,ResultHeader:st,Toolbar:ot},Te=_react.createContext.call(void 0, P);function Pe(t){let{Card:e,Marker:i,Popup:r,Sidebar:n,FilterPanel:s,Search:o,Empty:a,Loading:l,ResultHeader:c,Toolbar:d,children:v}=t,L={Card:_nullishCoalesce(e, () => (P.Card)),Marker:_nullishCoalesce(i, () => (P.Marker)),Popup:_nullishCoalesce(r, () => (P.Popup)),Sidebar:_nullishCoalesce(n, () => (P.Sidebar)),FilterPanel:_nullishCoalesce(s, () => (P.FilterPanel)),Search:_nullishCoalesce(o, () => (P.Search)),Empty:_nullishCoalesce(a, () => (P.Empty)),Loading:_nullishCoalesce(l, () => (P.Loading)),ResultHeader:_nullishCoalesce(c, () => (P.ResultHeader)),Toolbar:_nullishCoalesce(d, () => (P.Toolbar))};return _jsxruntime.jsx.call(void 0, Te.Provider,{value:L,children:v})}function F(){return _react.useContext.call(void 0, Te)}var $=_react.createContext.call(void 0, null);function y(){let t=_react.useContext.call(void 0, $);if(t===null)throw new Error("useListing must be used within a <ListingProvider>");return t}function S(){let t=y(),e=_react.useCallback.call(void 0, r=>t.subscribe(r),[t]),i=_react.useCallback.call(void 0, ()=>t.state,[t]);return _react.useSyncExternalStore.call(void 0, e,i,i)}function W(){let t=y(),e=S(),i=_react.useCallback.call(void 0, n=>t.applyFilters(n),[t]),r=_react.useCallback.call(void 0, (n,s)=>t.applyFilters({[n]:s}),[t]);return{filters:e.filters,set:i,setField:r}}function Y({className:t,groupClassName:e,hideLabels:i}={}){let r=y(),{FilterPanel:n}=F(),{filters:s}=W();return _jsxruntime.jsx.call(void 0, n,{children:_jsxruntime.jsx.call(void 0, "div",{className:_nullishCoalesce(t, () => ("space-y-5")),children:r.filters.list().map(o=>{if(typeof o.render=="string")return _jsxruntime.jsx.call(void 0, "div",{"data-filter":o.key,className:e},o.key);let a=o.render;return _jsxruntime.jsxs.call(void 0, "div",{className:e,children:[o.label&&!i&&_jsxruntime.jsx.call(void 0, "div",{className:"mb-1.5 text-[13px] font-medium text-foreground",children:o.label}),_jsxruntime.jsx.call(void 0, a,{value:o.fromParams(s),onChange:l=>{r.applyFilters(o.toParams(l))}})]},o.key)})})})}function R(){return S().results}function ut(t,e){if(t&&typeof t=="object"&&"id"in t){let i=t.id;if(typeof i=="string"||typeof i=="number")return i}return e}function Se({className:t}={}){let e=y(),{items:i}=R(),{pagination:r,selection:n}=S(),{Card:s,Empty:o,Loading:a}=F();return r.loading&&i.length===0?_jsxruntime.jsx.call(void 0, a,{}):i.length===0?_jsxruntime.jsx.call(void 0, o,{}):_jsxruntime.jsx.call(void 0, "div",{role:"list",className:t,children:i.map((l,c)=>{let d=ut(l,c);return _jsxruntime.jsx.call(void 0, s,{item:l,selected:n===d,onSelect:()=>e.selectPoint(e.primaryDatasetId,d)},d)})})}var gt={west:-179.9,south:-85,east:179.9,north:85},Ie=.1,we=.02;function ft(t){if(t.length===0)return null;let e=t[0].lng,i=t[0].lng,r=t[0].lat,n=t[0].lat;for(let{lat:a,lng:l}of t)l<e&&(e=l),l>i&&(i=l),a<r&&(r=a),a>n&&(n=a);let s=n>r?(n-r)*Ie:we,o=i>e?(i-e)*Ie:we;return{west:e-o,east:i+o,south:r-s,north:n+s}}function ke(t){let{center:e,zoom:i,fallback:r}=t,n=y(),s=S(),o=_react.useRef.call(void 0, null),a=_react.useRef.call(void 0, null),[l,c]=_react.useState.call(void 0, !1),d=_react.useRef.call(void 0, !1),v=_react.useRef.call(void 0, !1),L=_react.useRef.call(void 0, !1),p=n.map;return _react.useEffect.call(void 0, ()=>{let b=a.current;if(!p||!b)return;let u=[];for(let m of Object.keys(s.points)){if(s.layers[m]===!1)continue;let f=n.datasets.get(m),I=_nullishCoalesce(s.points[m], () => ([])),J={id:m,markers:I.map(E=>({id:E.id,position:E.position,iconUrl:_optionalChain([f, 'optionalAccess', _17 => _17.marker, 'access', _18 => _18.iconUrl, 'optionalCall', _19 => _19(E.entity)]),element:_optionalChain([f, 'optionalAccess', _20 => _20.marker, 'access', _21 => _21.element, 'optionalCall', _22 => _22(E.entity)])})),clustering:_optionalChain([f, 'optionalAccess', _23 => _23.clustering]),onMarkerClick:E=>n.selectPoint(m,E)};u.push(p.renderLayer(b,J))}return()=>{u.forEach(m=>m())}},[n,p,l,s.points,s.layers]),_react.useEffect.call(void 0, ()=>{if(!o.current||!p)return;let b=o.current,u=!1,m=null;return(async()=>{let f=await p.mount(b,{center:e,zoom:i});if(u){p.destroy(f);return}a.current=f,m=p.onBoundsChange(f,I=>{L.current?L.current=!1:v.current=!0,n.loadPoints(I)}),c(!0),n.loadPoints(gt)})(),()=>{u=!0,_optionalChain([m, 'optionalCall', _24 => _24()]),a.current&&(p.destroy(a.current),a.current=null),c(!1)}},[n,p]),_react.useEffect.call(void 0, ()=>{let b=a.current;if(!p||!b||e||d.current||v.current)return;let u=[];for(let f of Object.keys(s.points))if(s.layers[f]!==!1)for(let I of _nullishCoalesce(s.points[f], () => ([])))u.push(I.position);let m=ft(u);m&&(d.current=!0,L.current=!0,p.fitBounds(b,m))},[p,e,l,s.points,s.layers]),_jsxruntime.jsx.call(void 0, "div",{ref:o,className:!p&&r?"flex h-full min-h-0 w-full items-center justify-center":"h-full min-h-0 w-full",children:!p&&r})}function Ee(){let t=y(),{results:e,pagination:i}=S();return e.nextCursor==null?null:_jsxruntime.jsx.call(void 0, "button",{type:"button",disabled:i.loading,onClick:()=>{t.loadPage()},children:"Load more"})}function xe(){let{items:t,total:e}=R(),{ResultHeader:i}=F();return _jsxruntime.jsx.call(void 0, i,{count:t.length,total:e})}function Ne(t,e){let i=y(),r=_react.useRef.call(void 0, e);r.current=e,_react.useEffect.call(void 0, ()=>i.on(t,n=>r.current(n)),[i,t])}function Me(t){let{children:e,...i}=t,[r]=_react.useState.call(void 0, ()=>i),[n,s]=_react.useState.call(void 0, null);return _react.useEffect.call(void 0, ()=>{let o=new K({datasets:r.datasets,filters:r.filters,config:r.config,map:r.map,initialFilters:r.initialFilters,primaryDatasetId:r.primaryDatasetId});return r.urlSync&&r.urlSync.start(o),s(o),()=>{r.urlSync&&r.urlSync.stop(),o.dispose(),s(a=>a===o?null:a)}},[r]),n?_jsxruntime.jsx.call(void 0, $.Provider,{value:n,children:e}):null}function M(t){return typeof t!="number"?t:new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t)}function Ft(t){return t?"rle-card rle-card--selected":"rle-card"}function te({item:t,selected:e,onSelect:i}){let r=_nullishCoalesce(t, () => ({})),n=Ft(e),s=_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[r.imageUrl?_jsxruntime.jsx.call(void 0, "img",{src:r.imageUrl,alt:_nullishCoalesce(r.title, () => ("")),className:"rle-card-media"}):_jsxruntime.jsx.call(void 0, "div",{className:"rle-card-media rle-card-media--placeholder","aria-hidden":"true"}),_jsxruntime.jsxs.call(void 0, "div",{className:"rle-card-body",children:[r.title&&_jsxruntime.jsx.call(void 0, "span",{className:"rle-card-title",children:r.title}),r.subtitle&&_jsxruntime.jsx.call(void 0, "span",{className:"rle-card-address",children:r.subtitle}),r.badge&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-card-info",children:_jsxruntime.jsx.call(void 0, "span",{className:"rle-card-info-item",children:r.badge})}),r.price!=null&&_jsxruntime.jsx.call(void 0, "span",{className:"rle-card-price",children:M(r.price)})]})]});return i?_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:i,"aria-pressed":_nullishCoalesce(e, () => (!1)),className:n,children:s}):_jsxruntime.jsx.call(void 0, "article",{className:n,children:s})}function ie(t){return _jsxruntime.jsxs.call(void 0, "div",{role:"status",className:"rle-empty",children:[_jsxruntime.jsxs.call(void 0, "svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",className:"rle-empty-icon","aria-hidden":"true",children:[_jsxruntime.jsx.call(void 0, "circle",{cx:"11",cy:"11",r:"7"}),_jsxruntime.jsx.call(void 0, "path",{d:"m21 21-4.3-4.3"})]}),_jsxruntime.jsx.call(void 0, "p",{className:"rle-empty-title",children:"No results"}),_jsxruntime.jsx.call(void 0, "p",{className:"rle-empty-hint",children:"Try adjusting your filters or search terms."})]})}function re({children:t}){return _jsxruntime.jsx.call(void 0, "div",{className:"rle-filter-panel",children:t})}function ne(t){return _jsxruntime.jsx.call(void 0, "div",{className:"rle-loading",role:"status","aria-busy":"true","aria-label":"Loading results",children:Array.from({length:3}).map((e,i)=>_jsxruntime.jsxs.call(void 0, "div",{className:"rle-loading-item",children:[_jsxruntime.jsx.call(void 0, "div",{className:"rle-skeleton",style:{aspectRatio:"4 / 3",width:"100%"}}),_jsxruntime.jsx.call(void 0, "div",{className:"rle-skeleton",style:{height:16,width:"65%"}}),_jsxruntime.jsx.call(void 0, "div",{className:"rle-skeleton",style:{height:12,width:"35%"}})]},i))})}function se({point:t}){let e=_nullishCoalesce(t.entity, () => ({}));return _jsxruntime.jsx.call(void 0, "span",{className:"rle-pin",children:e.price!=null?M(e.price):""})}function ae({entity:t,onClose:e}){let i=_nullishCoalesce(t, () => ({}));return _jsxruntime.jsxs.call(void 0, "div",{className:"rle-popup",role:"group","aria-label":"Location details",children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:e,"aria-label":"Close",className:"rle-popup-close",children:_jsxruntime.jsxs.call(void 0, "svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"16",height:"16","aria-hidden":"true",children:[_jsxruntime.jsx.call(void 0, "path",{d:"M18 6 6 18"}),_jsxruntime.jsx.call(void 0, "path",{d:"m6 6 12 12"})]})}),_jsxruntime.jsxs.call(void 0, "div",{children:[i.title&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-card-title",children:i.title}),i.subtitle&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-card-address",children:i.subtitle}),i.price!=null&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-card-price",children:M(i.price)})]})]})}function le({count:t,total:e}){let i=e!=null&&e!==t?`${t} of ${e} results`:`${t} results`;return _jsxruntime.jsx.call(void 0, "div",{className:"rle-result-header",children:i})}function de({value:t,onChange:e,placeholder:i}){return _jsxruntime.jsx.call(void 0, "input",{type:"search",value:t,placeholder:i,onChange:r=>e(r.target.value),"aria-label":_nullishCoalesce(i, () => ("Search")),className:"rle-input"})}function pe({children:t}){return _jsxruntime.jsx.call(void 0, "aside",{className:"rle-sidebar",children:t})}function ce({children:t}){return _jsxruntime.jsx.call(void 0, "div",{className:"rle-toolbar",children:t})}var _e={Card:te,Marker:se,Popup:ae,Sidebar:pe,FilterPanel:re,Search:de,Empty:ie,Loading:ne,ResultHeader:le,Toolbar:ce};function Be({view:t,onViewChange:e}){return _jsxruntime.jsx.call(void 0, "nav",{className:"rle-bottom-nav","aria-label":"Listing navigation",children:_jsxruntime.jsxs.call(void 0, "div",{className:"rle-viewtoggle",role:"group","aria-label":"View",children:[_jsxruntime.jsxs.call(void 0, "button",{type:"button",className:`rle-viewtoggle__btn${t==="list"?" rle-viewtoggle__btn--active":""}`,"aria-pressed":t==="list",onClick:()=>e("list"),children:[_jsxruntime.jsx.call(void 0, Rt,{}),"List"]}),_jsxruntime.jsxs.call(void 0, "button",{type:"button",className:`rle-viewtoggle__btn${t==="map"?" rle-viewtoggle__btn--active":""}`,"aria-pressed":t==="map",onClick:()=>e("map"),children:[_jsxruntime.jsx.call(void 0, Mt,{}),"Map"]})]})})}function Rt(){return _jsxruntime.jsxs.call(void 0, "svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"16",height:"16","aria-hidden":"true",children:[_jsxruntime.jsx.call(void 0, "line",{x1:"8",y1:"6",x2:"20",y2:"6"}),_jsxruntime.jsx.call(void 0, "line",{x1:"8",y1:"12",x2:"20",y2:"12"}),_jsxruntime.jsx.call(void 0, "line",{x1:"8",y1:"18",x2:"20",y2:"18"}),_jsxruntime.jsx.call(void 0, "line",{x1:"4",y1:"6",x2:"4.01",y2:"6"}),_jsxruntime.jsx.call(void 0, "line",{x1:"4",y1:"12",x2:"4.01",y2:"12"}),_jsxruntime.jsx.call(void 0, "line",{x1:"4",y1:"18",x2:"4.01",y2:"18"})]})}function Mt(){return _jsxruntime.jsxs.call(void 0, "svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"16",height:"16","aria-hidden":"true",children:[_jsxruntime.jsx.call(void 0, "polygon",{points:"1 6 8 3 16 6 23 3 23 18 16 21 8 18 1 21 1 6"}),_jsxruntime.jsx.call(void 0, "line",{x1:"8",y1:"3",x2:"8",y2:"18"}),_jsxruntime.jsx.call(void 0, "line",{x1:"16",y1:"6",x2:"16",y2:"21"})]})}var _reactdom = require('react-dom');function He({open:t,onOpenChange:e,title:i,children:r,footer:n}){let s=_react.useRef.call(void 0, null),[o,a]=_react.useState.call(void 0, !1),[l,c]=_react.useState.call(void 0, !1);return _react.useEffect.call(void 0, ()=>{if(!t){c(!1),a(!1);return}a(!0);let d=requestAnimationFrame(()=>c(!0));return()=>cancelAnimationFrame(d)},[t]),_react.useEffect.call(void 0, ()=>{if(!o)return;let d=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=d}},[o]),_react.useEffect.call(void 0, ()=>{if(!o)return;_optionalChain([s, 'access', _25 => _25.current, 'optionalAccess', _26 => _26.focus, 'call', _27 => _27()]);function d(v){v.key==="Escape"&&e(!1)}return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[o,e]),!o||typeof document>"u"?null:_reactdom.createPortal.call(void 0, _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "div",{className:`rle-sheet-backdrop${l?" rle-sheet-backdrop--open":""}`,onClick:()=>e(!1),"aria-hidden":"true"}),_jsxruntime.jsxs.call(void 0, "div",{ref:s,className:`rle-sheet${l?" rle-sheet--open":""}`,role:"dialog","aria-modal":"true","aria-label":i,tabIndex:-1,children:[_jsxruntime.jsx.call(void 0, "div",{className:"rle-sheet__handle","aria-hidden":"true"}),_jsxruntime.jsxs.call(void 0, "div",{className:"rle-sheet__header",children:[i&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-sheet__title",children:i}),_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"rle-sheet__close",onClick:()=>e(!1),"aria-label":"Close",children:_jsxruntime.jsx.call(void 0, _t,{})})]}),_jsxruntime.jsx.call(void 0, "div",{className:"rle-sheet__body",children:r}),n&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-sheet__footer",children:n})]})]}),document.body)}function _t(){return _jsxruntime.jsxs.call(void 0, "svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"16",height:"16","aria-hidden":"true",children:[_jsxruntime.jsx.call(void 0, "path",{d:"M18 6 6 18"}),_jsxruntime.jsx.call(void 0, "path",{d:"m6 6 12 12"})]})}function ze({search:t,onFiltersClick:e,filterCount:i=0,action:r}){let{Search:n}=F();return _jsxruntime.jsxs.call(void 0, "header",{className:"rle-mobile-header",children:[t&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-mobile-header__search",children:_jsxruntime.jsx.call(void 0, n,{value:t.value,onChange:t.onChange,placeholder:t.placeholder})}),_jsxruntime.jsxs.call(void 0, "button",{type:"button",className:"rle-btn rle-mobile-header__btn",onClick:e,children:[_jsxruntime.jsx.call(void 0, At,{}),_jsxruntime.jsx.call(void 0, "span",{children:"Filters"}),i>0&&_jsxruntime.jsx.call(void 0, "span",{className:"rle-mobile-header__count",children:i})]}),r&&_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"rle-btn rle-mobile-header__btn rle-mobile-header__btn--icon",onClick:r.onClick,"aria-label":r.label,children:_nullishCoalesce(r.icon, () => (_jsxruntime.jsx.call(void 0, Ht,{})))})]})}function At(){return _jsxruntime.jsxs.call(void 0, "svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[_jsxruntime.jsx.call(void 0, "line",{x1:"4",y1:"6",x2:"20",y2:"6"}),_jsxruntime.jsx.call(void 0, "circle",{cx:"9",cy:"6",r:"2",fill:"currentColor",stroke:"none"}),_jsxruntime.jsx.call(void 0, "line",{x1:"4",y1:"12",x2:"20",y2:"12"}),_jsxruntime.jsx.call(void 0, "circle",{cx:"15",cy:"12",r:"2",fill:"currentColor",stroke:"none"}),_jsxruntime.jsx.call(void 0, "line",{x1:"4",y1:"18",x2:"20",y2:"18"}),_jsxruntime.jsx.call(void 0, "circle",{cx:"11",cy:"18",r:"2",fill:"currentColor",stroke:"none"})]})}function Ht(){return _jsxruntime.jsxs.call(void 0, "svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[_jsxruntime.jsx.call(void 0, "line",{x1:"12",y1:"5",x2:"12",y2:"19"}),_jsxruntime.jsx.call(void 0, "line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}var Ut=_jsxruntime.jsx.call(void 0, "div",{className:"rle-empty",children:"Map unavailable"});function Vt(){let t=_react.useRef.call(void 0, null),[e,i]=_react.useState.call(void 0, !0),[r,n]=_react.useState.call(void 0, !0);return _react.useEffect.call(void 0, ()=>{let s=t.current;if(!s)return;let o=()=>{let{clientWidth:v,scrollLeft:L,scrollWidth:p}=s;i(L<=0),n(L+v>=p-1)},a=0,l=()=>{a||(a=requestAnimationFrame(()=>{a=0,o()}))};o(),s.addEventListener("scroll",o,{passive:!0});let c,d;return typeof ResizeObserver<"u"&&(c=new ResizeObserver(o),c.observe(s)),typeof MutationObserver<"u"&&(d=new MutationObserver(l),d.observe(s,{characterData:!0,childList:!0,subtree:!0})),()=>{s.removeEventListener("scroll",o),_optionalChain([c, 'optionalAccess', _28 => _28.disconnect, 'call', _29 => _29()]),_optionalChain([d, 'optionalAccess', _30 => _30.disconnect, 'call', _31 => _31()]),a&&cancelAnimationFrame(a)}},[]),{atEnd:r,atStart:e,ref:t}}function Ve({search:t,toolbarEnd:e,mobileAction:i,autoFetch:r=!0,hasMap:n,mapCenter:s,mapZoom:o,className:a}){let l=y(),{Search:c}=F(),d=R(),{filters:v,set:L}=W(),p=_nullishCoalesce(n, () => (l.map!=null)),[b,u]=_react.useState.call(void 0, "list"),[m,f]=_react.useState.call(void 0, !1),{atEnd:I,atStart:J,ref:E}=Vt(),O=t?{value:String(_nullishCoalesce(v[t.filterKey], () => (""))),onChange:je=>{L({[t.filterKey]:je||void 0})},placeholder:t.placeholder}:void 0;_react.useEffect.call(void 0, ()=>{r!==!1&&l.applyFilters({})},[l,r]);let $e=()=>{L(l.filters.clearedParams())},We=l.filters.activeKeys(v).length,qe=_nullishCoalesce(d.total, () => (d.items.length));return _jsxruntime.jsxs.call(void 0, "div",{className:a?`rle-app ${a}`:"rle-app",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"rle-filter-bar",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"rle-filter-bar__scroll",ref:E,children:[O&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-filter-bar__search",children:_jsxruntime.jsx.call(void 0, c,{value:O.value,onChange:O.onChange,placeholder:O.placeholder})}),_jsxruntime.jsx.call(void 0, Y,{className:"rle-filters-row",groupClassName:"rle-filter-group",hideLabels:!0})]}),!J&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-filter-bar__fade rle-filter-bar__fade--start","aria-hidden":"true"}),!I&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-filter-bar__fade rle-filter-bar__fade--end","aria-hidden":"true"})]}),_jsxruntime.jsx.call(void 0, ze,{search:O,onFiltersClick:()=>f(!0),filterCount:We,action:i}),_jsxruntime.jsxs.call(void 0, "div",{className:`rle-body ${p?"rle-split":"rle-body--list-only"}`,"data-mobile-view":b,children:[_jsxruntime.jsxs.call(void 0, "div",{className:"rle-list",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"rle-list-header",children:[_jsxruntime.jsx.call(void 0, xe,{}),e&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-list-header__toolbar",children:e})]}),_jsxruntime.jsx.call(void 0, Se,{className:"rle-list-grid"}),_jsxruntime.jsx.call(void 0, Ee,{})]}),p&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-map",children:_jsxruntime.jsx.call(void 0, ke,{center:s,zoom:o,fallback:Ut})})]}),p&&_jsxruntime.jsx.call(void 0, Be,{view:b,onViewChange:u}),_jsxruntime.jsx.call(void 0, He,{title:"Filters",open:m,onOpenChange:f,footer:_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"rle-btn rle-btn--ghost",onClick:$e,children:"Clear all"}),_jsxruntime.jsxs.call(void 0, "button",{type:"button",className:"rle-btn rle-btn--primary",onClick:()=>f(!1),children:["Show ",qe," results"]})]}),children:_jsxruntime.jsx.call(void 0, Y,{className:"rle-filter-stack",groupClassName:"rle-filter-group"})})]})}function Ke(t){return"provider"in t}function jt(t){let e=t!=null&&!Ke(t),i=e?t.apiKey:void 0,r=e?t.mapId:void 0,n=e?t.mapOptions:void 0,s=e?t.styles:void 0,[o,a]=_react.useState.call(void 0, ()=>!t||Ke(t)?{ready:!0,provider:_optionalChain([t, 'optionalAccess', _32 => _32.provider])}:{ready:!1});return _react.useEffect.call(void 0, ()=>{if(!i)return;let l=!1;return Promise.resolve().then(() => _interopRequireWildcard(require("./maps/google/index.cjs"))).then(({googleProvider:c})=>{l||a({ready:!0,provider:c({apiKey:i,mapId:r,mapOptions:n,styles:s})})}),()=>{l=!0}},[i,r]),o}function Qt({onFiltersChange:t}){let e=_react.useRef.call(void 0, t);return e.current=t,Ne("FiltersChanged",i=>{i.type==="FiltersChanged"&&e.current(i.filters)}),null}function mn(t){let{datasets:e,filters:i,map:r,components:n,initialFilters:s,onFiltersChange:o,mobileAction:a,search:l,toolbarEnd:c,config:d,autoFetch:v,className:L}=t,{ready:p,provider:b}=jt(r);if(!p)return null;let u=[];for(let I of e)u.push(ve(I));i&&u.push(Le(i)),b&&u.push(he(b)),s&&u.push(be(s)),d&&u.push(ye(d));let m=fe(...u),f={..._e,...n};return _jsxruntime.jsxs.call(void 0, Me,{...m,children:[o&&_jsxruntime.jsx.call(void 0, Qt,{onFiltersChange:o}),_jsxruntime.jsx.call(void 0, Pe,{...f,children:_jsxruntime.jsx.call(void 0, Ve,{className:L,search:l,toolbarEnd:c,mobileAction:a,autoFetch:v,mapCenter:_optionalChain([r, 'optionalAccess', _33 => _33.center]),mapZoom:_optionalChain([r, 'optionalAccess', _34 => _34.zoom])})})]})}exports.a = H; exports.b = N; exports.c = z; exports.d = U; exports.e = ge; exports.f = V; exports.g = K; exports.h = fe; exports.i = ye; exports.j = he; exports.k = ve; exports.l = Le; exports.m = pi; exports.n = be; exports.o = ci; exports.p = Pe; exports.q = F; exports.r = $; exports.s = y; exports.t = S; exports.u = W; exports.v = Y; exports.w = R; exports.x = Se; exports.y = ke; exports.z = Ee; exports.A = xe; exports.B = Ne; exports.C = Me; exports.D = te; exports.E = ie; exports.F = re; exports.G = ne; exports.H = se; exports.I = ae; exports.J = le; exports.K = de; exports.L = pe; exports.M = ce; exports.N = _e; exports.O = Be; exports.P = He; exports.Q = Ve; exports.R = mn;
@@ -1,67 +0,0 @@
1
- type EntityId = string | number;
2
- interface Bounds {
3
- west: number;
4
- south: number;
5
- east: number;
6
- north: number;
7
- }
8
- interface LatLng {
9
- lat: number;
10
- lng: number;
11
- }
12
- interface PageRequest {
13
- cursor?: string | null;
14
- limit: number;
15
- }
16
- interface Page<T> {
17
- items: T[];
18
- nextCursor: string | null;
19
- total?: number;
20
- }
21
- interface MapPoint<TEntity = unknown> {
22
- id: EntityId;
23
- position: LatLng;
24
- entity: TEntity;
25
- }
26
- type QueryParams = Record<string, string | undefined>;
27
- interface EntityAdapter<TEntity, TFilters> {
28
- list(filters: TFilters, page: PageRequest): Promise<Page<TEntity>>;
29
- getPoints(filters: TFilters, bounds: Bounds): Promise<MapPoint<TEntity>[]>;
30
- getById?(id: EntityId): Promise<TEntity>;
31
- }
32
-
33
- /**
34
- * Providers that need an API key take it via their factory (e.g. `googleProvider({ apiKey })`),
35
- * not per-mount.
36
- */
37
- interface MapInitOptions {
38
- apiKey?: string;
39
- center?: LatLng;
40
- zoom?: number;
41
- }
42
- interface MapHandle {
43
- readonly raw: unknown;
44
- }
45
- interface RenderedLayer {
46
- id: string;
47
- markers: Array<{
48
- id: string | number;
49
- position: LatLng;
50
- iconUrl?: string;
51
- element?: HTMLElement;
52
- }>;
53
- clustering?: {
54
- maxZoom?: number;
55
- } | false;
56
- onMarkerClick?(id: string | number): void;
57
- }
58
- type Unsubscribe = () => void;
59
- interface MapProvider {
60
- mount(el: HTMLElement, opts: MapInitOptions): Promise<MapHandle> | MapHandle;
61
- renderLayer(handle: MapHandle, layer: RenderedLayer): Unsubscribe;
62
- onBoundsChange(handle: MapHandle, cb: (b: Bounds) => void): Unsubscribe;
63
- fitBounds(handle: MapHandle, b: Bounds): void;
64
- destroy(handle: MapHandle): void;
65
- }
66
-
67
- export type { Bounds as B, EntityId as E, LatLng as L, MapPoint as M, Page as P, QueryParams as Q, RenderedLayer as R, Unsubscribe as U, MapProvider as a, EntityAdapter as b, MapHandle as c, MapInitOptions as d, PageRequest as e };
@@ -1,67 +0,0 @@
1
- type EntityId = string | number;
2
- interface Bounds {
3
- west: number;
4
- south: number;
5
- east: number;
6
- north: number;
7
- }
8
- interface LatLng {
9
- lat: number;
10
- lng: number;
11
- }
12
- interface PageRequest {
13
- cursor?: string | null;
14
- limit: number;
15
- }
16
- interface Page<T> {
17
- items: T[];
18
- nextCursor: string | null;
19
- total?: number;
20
- }
21
- interface MapPoint<TEntity = unknown> {
22
- id: EntityId;
23
- position: LatLng;
24
- entity: TEntity;
25
- }
26
- type QueryParams = Record<string, string | undefined>;
27
- interface EntityAdapter<TEntity, TFilters> {
28
- list(filters: TFilters, page: PageRequest): Promise<Page<TEntity>>;
29
- getPoints(filters: TFilters, bounds: Bounds): Promise<MapPoint<TEntity>[]>;
30
- getById?(id: EntityId): Promise<TEntity>;
31
- }
32
-
33
- /**
34
- * Providers that need an API key take it via their factory (e.g. `googleProvider({ apiKey })`),
35
- * not per-mount.
36
- */
37
- interface MapInitOptions {
38
- apiKey?: string;
39
- center?: LatLng;
40
- zoom?: number;
41
- }
42
- interface MapHandle {
43
- readonly raw: unknown;
44
- }
45
- interface RenderedLayer {
46
- id: string;
47
- markers: Array<{
48
- id: string | number;
49
- position: LatLng;
50
- iconUrl?: string;
51
- element?: HTMLElement;
52
- }>;
53
- clustering?: {
54
- maxZoom?: number;
55
- } | false;
56
- onMarkerClick?(id: string | number): void;
57
- }
58
- type Unsubscribe = () => void;
59
- interface MapProvider {
60
- mount(el: HTMLElement, opts: MapInitOptions): Promise<MapHandle> | MapHandle;
61
- renderLayer(handle: MapHandle, layer: RenderedLayer): Unsubscribe;
62
- onBoundsChange(handle: MapHandle, cb: (b: Bounds) => void): Unsubscribe;
63
- fitBounds(handle: MapHandle, b: Bounds): void;
64
- destroy(handle: MapHandle): void;
65
- }
66
-
67
- export type { Bounds as B, EntityId as E, LatLng as L, MapPoint as M, Page as P, QueryParams as Q, RenderedLayer as R, Unsubscribe as U, MapProvider as a, EntityAdapter as b, MapHandle as c, MapInitOptions as d, PageRequest as e };