react-listing-engine 0.12.5 → 0.12.7
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/CHANGELOG.md +12 -0
- package/dist/chunk-2N3ICJ5L.js +2 -0
- package/dist/chunk-XVPGWJW3.cjs +2 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +10 -3
- package/dist/index.d.ts +10 -3
- package/dist/index.js +1 -1
- package/dist/maps/google/index.cjs +1 -1
- package/dist/maps/google/index.js +1 -1
- package/dist/styled/index.cjs +1 -1
- package/dist/styled/index.js +1 -1
- package/dist/testing/index.cjs +1 -1
- package/dist/testing/index.d.cts +8 -0
- package/dist/testing/index.d.ts +8 -0
- package/dist/testing/index.js +1 -1
- package/package.json +10 -10
- package/dist/chunk-NW4P53OH.js +0 -2
- package/dist/chunk-YIN4LD7K.cjs +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# react-listing-engine
|
|
2
2
|
|
|
3
|
+
## 0.12.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Reconcile overlay markers by id when a layer re-renders instead of rebuilding the whole layer. A marker whose id is still present keeps its overlay and DOM node (re-anchored if it moved, its content swapped only when it changed), so a points reload -- one per map settle -- no longer blinks every marker and reloads every logo image. Advanced-marker mode is unchanged.
|
|
8
|
+
|
|
9
|
+
## 0.12.6
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Internal cleanup: the pending-fit replay in `setMapHandle` delegates through `fitBounds` itself instead of duplicating the provider call, so the engine has exactly one delegation site. No behavior change.
|
|
14
|
+
|
|
3
15
|
## 0.12.5
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var ie=class{state;listeners=new Set;constructor(e){this.state=this.freezeState({filters:{...e.filters},results:e.results?{items:[...e.results.items],nextCursor:e.results.nextCursor,total:e.results.total}:{items:[],nextCursor:null},bounds:null,selection:null,hovered:null,pagination:{mode:e.mode??"paged",loading:!1,loaded:e.results!=null,pageIndex:0},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},pagination:{...this.state.pagination,loaded:!0}})}appendResults(e){this.setState({results:{items:[...this.state.results.items,...e.items],nextCursor:e.nextCursor,total:e.total},pagination:{...this.state.pagination,loaded:!0}})}setBounds(e){this.setState({bounds:e?{...e}:null})}setSelection(e){this.setState({selection:e})}setHovered(e){this.setState({hovered:e})}setLayerVisible(e,i){this.setState({layers:{...this.state.layers,[e]:i}})}setLoading(e){this.setState({pagination:{...this.state.pagination,loading:e}})}setPageIndex(e){this.setState({pagination:{...this.state.pagination,pageIndex: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 j=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(),n=e.filter(s=>this.defs.has(s));n.forEach((s,o)=>{this.defs.get(s).order=o});let r=new Set(n);return i.filter(s=>!r.has(s.key)).forEach((s,o)=>{s.order=n.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(n=>Object.hasOwn(e,n.key)).map(n=>n.toParams(e[n.key])).reduce((n,r)=>({...n,...r}),{})}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 ne=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 re=class{map=new Map;dispose(){this.map.clear()}emit(e){let i=this.map.get(e.type);if(i)for(let r of[...i])r(e);let n=this.map.get("*");if(n)for(let r of[...n])r(e)}on(e,i){let n=this.map.get(e);return n||(n=new Set,this.map.set(e,n)),n.add(i),()=>{n.delete(i)}}};var Ke={pagination:"paged",pageSize:20,debounceMs:250};var se=class{options;constructor(e){this.options=Object.freeze({...Ke,...e})}};var oe=class{filters;map;datasets;primaryDatasetId;store;disposed=!1;emitter=new re;config;debounceTimer=null;debounceResolve=null;queryToken=0;pointsToken=0;mapHandle=null;pendingFit=null;constructor(e){this.datasets=e.datasets,this.filters=e.filters??new j,this.map=e.map,this.config=new se(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 ie({filters:e.initialFilters??{},mode:this.config.options.pagination,results:e.initialResults})}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,n=this.config.options.debounceMs;return n<=0?this.runQuery(i):new Promise(r=>{this.debounceResolve=r,this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.debounceResolve=null,r(this.runQuery(i))},n)})}async loadPage(){let e=this.state.results.nextCursor;if(e===null)return;let i=++this.queryToken,n=this.primaryDataset();this.store.setLoading(!0);try{let r=await n.adapter.list(this.currentFilters(),{cursor:e,limit:this.config.options.pageSize});if(i!==this.queryToken)return;this.config.options.pagination==="infinite"?this.store.appendResults(r):this.store.setResults(r),this.emitter.emit({type:"ResultsLoaded",datasetId:this.primaryDatasetId,count:r.items.length})}finally{i===this.queryToken&&this.store.setLoading(!1)}}async goToPage(e){if(e<0)return;let i=++this.queryToken,n=this.primaryDataset();this.store.setLoading(!0);try{let r=await n.adapter.list(this.currentFilters(),{offset:e*this.config.options.pageSize,limit:this.config.options.pageSize});if(i!==this.queryToken)return;this.store.setResults(r),this.store.setPageIndex(e),this.emitter.emit({type:"ResultsLoaded",datasetId:this.primaryDatasetId,count:r.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(),n=++this.pointsToken;await Promise.allSettled(this.datasets.visibleIds().map(async r=>{let s=this.datasets.get(r);if(!s)return;let o=await s.adapter.getPoints(i,e);n===this.pointsToken&&this.store.setPoints(r,o)}))}setMapHandle(e){if(this.mapHandle=e,!e||!this.pendingFit)return;let{bounds:i,options:n}=this.pendingFit;this.pendingFit=null,this.fitBounds(i,n)}fitBounds(e,i){if(this.map){if(!this.mapHandle){this.pendingFit={bounds:e,options:i};return}this.map.fitBounds(this.mapHandle,e,i)}}selectPoint(e,i){this.store.setSelection(i);let n=this.state.points[e]?.find(r=>r.id===i);n&&this.emitter.emit({type:"PointClicked",datasetId:e,id:n.id,entity:n.entity})}setHovered(e,i){this.store.setHovered(i)}toggleLayer(e){let n=!(this.state.layers[e]??!0);this.store.setLayerVisible(e,n),this.emitter.emit({type:"LayerToggled",datasetId:e,visible:n})}subscribe(e){return this.store.subscribe(e)}on(e,i){return this.emitter.on(e,i)}get isDisposed(){return this.disposed}attachMap(e){this.disposed||this.map===e||this.map||(this.map=e,this.store.setFilters({}))}dispose(){this.clearDebounce(),this.emitter.dispose(),this.mapHandle=null,this.disposed=!0}async runQuery(e){if(e!==this.queryToken)return;let i=this.primaryDataset();this.store.setLoading(!0);try{let n=await i.adapter.list(this.currentFilters(),{cursor:null,limit:this.config.options.pageSize});if(e!==this.queryToken)return;this.store.setResults(n),this.store.setPageIndex(0),this.emitter.emit({type:"ResultsLoaded",datasetId:this.primaryDatasetId,count:n.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 Ue(...t){let e={config:{},filters:new j,datasets:new ne};for(let i of t)i(e);return e}var Ve=t=>e=>{e.config={...e.config,...t}},qe=t=>e=>{e.map=t},$e=t=>e=>{e.datasets.add(t)},We=t=>e=>{t(e.filters)},Ki=t=>e=>{e.urlSync=t},je=t=>e=>{e.initialFilters=t},Ge=t=>e=>{e.initialResults=t},Ui=t=>e=>{e.primaryDatasetId=t};import{createContext as kt,useContext as St}from"react";import{jsx as k,jsxs as Xe}from"react/jsx-runtime";function Ct(t){return String(t?.title??"")}var It=({item:t})=>k("div",{children:Ct(t)}),Et=()=>k("div",{}),he=()=>k("div",{}),xt=({children:t})=>k("div",{children:t}),Rt=({children:t})=>k("div",{children:t}),Nt=({value:t,onChange:e,placeholder:i})=>k("input",{type:"search",value:t,placeholder:i,onChange:n=>e(n.target.value),"aria-label":i??"Search"}),Mt=()=>k("div",{role:"status",children:"No results"}),Dt=()=>k("div",{role:"status","aria-busy":"true",children:"Loading\u2026"}),Bt=({count:t})=>Xe("div",{children:[t," results"]}),Ot=({children:t})=>k("div",{children:t}),_t=({view:t,onViewChange:e})=>Xe("nav",{"aria-label":"Listing navigation",children:[k("button",{type:"button","aria-pressed":t==="list",onClick:()=>e("list"),children:"List"}),k("button",{type:"button","aria-pressed":t==="map",onClick:()=>e("map"),children:"Map"})]}),w={BottomNav:_t,Card:It,Marker:Et,Popup:he,Sidebar:xt,FilterPanel:Rt,Search:Nt,Empty:Mt,Loading:Dt,ResultHeader:Bt,Toolbar:Ot},Qe=kt(w);function Ze(t){let{BottomNav:e,Card:i,Marker:n,Popup:r,Sidebar:s,FilterPanel:o,Search:a,Empty:p,Loading:l,ResultHeader:d,Toolbar:g,children:v}=t,E={BottomNav:e??w.BottomNav,Card:i??w.Card,Marker:n??w.Marker,Popup:r??w.Popup,Sidebar:s??w.Sidebar,FilterPanel:o??w.FilterPanel,Search:a??w.Search,Empty:p??w.Empty,Loading:l??w.Loading,ResultHeader:d??w.ResultHeader,Toolbar:g??w.Toolbar};return k(Qe.Provider,{value:E,children:v})}function S(){return St(Qe)}import{createContext as At}from"react";var ae=At(null);import{useContext as Ht}from"react";function L(){let t=Ht(ae);if(t===null)throw new Error("useListing must be used within a <ListingProvider>");return t}import{useCallback as Je,useSyncExternalStore as zt}from"react";function C(){let t=L(),e=Je(n=>t.subscribe(n),[t]),i=Je(()=>t.state,[t]);return zt(e,i,i)}import{useCallback as Ye}from"react";function le(){let t=L(),e=C(),i=Ye(r=>t.applyFilters(r),[t]),n=Ye((r,s)=>t.applyFilters({[r]:s}),[t]);return{filters:e.filters,set:i,setField:n}}import{jsx as Y,jsxs as Kt}from"react/jsx-runtime";function ve({className:t,groupClassName:e,hideLabels:i,draft:n,onDraftChange:r}={}){let s=L(),{FilterPanel:o}=S(),{filters:a}=le(),p=n!==void 0&&r!==void 0,l=p?n:a;return Y(o,{children:Y("div",{className:t??"space-y-5",children:s.filters.list().map(d=>{if(typeof d.render=="string")return Y("div",{"data-filter":d.key,className:e},d.key);let g=d.render;return Kt("div",{className:e,children:[d.label&&!i&&Y("div",{className:"mb-1.5 text-[13px] font-medium text-foreground",children:d.label}),Y(g,{value:d.fromParams(l),onChange:v=>p?r(d.toParams(v)):void s.applyFilters(d.toParams(v))})]},d.key)})})})}function G(){return C().results}import{jsx as de}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 et({className:t}={}){let e=L(),{items:i}=G(),{pagination:n,selection:r}=C(),{Card:s,Empty:o,Loading:a}=S();return i.length===0&&(n.loading||!n.loaded)?de(a,{}):i.length===0?de(o,{}):de("div",{role:"list",className:t,children:i.map((p,l)=>{let d=Ut(p,l);return de(s,{item:p,selected:r===d,onSelect:()=>e.selectPoint(e.primaryDatasetId,d)},d)})})}import{useEffect as Q,useRef as R,useState as tt}from"react";import{createPortal as Vt}from"react-dom";import{jsx as be,jsxs as rt}from"react/jsx-runtime";var qt={west:-179.9,south:-85,east:179.9,north:85},it=.1,nt=.02;function $t(t){if(t.length===0)return null;let e=t[0].lng,i=t[0].lng,n=t[0].lat,r=t[0].lat;for(let{lat:a,lng:p}of t)p<e&&(e=p),p>i&&(i=p),a<n&&(n=a),a>r&&(r=a);let s=r>n?(r-n)*it:nt,o=i>e?(i-e)*it:nt;return{west:e-o,east:i+o,south:n-s,north:r+s}}function st(t){let{center:e,zoom:i,fallback:n,mapControls:r,onMapReady:s}=t,o=L(),a=C(),p=R(s);p.current=s;let l=R(null),d=R(null),g=R(null),[v,E]=tt(!1),K=R(!1),F=R(!1),D=R(!1),u=o.map,U=R(new Map);Q(()=>{let f=g.current;if(!u||!f)return;let h=U.current,T=new Set;for(let c of Object.keys(a.points)){if(a.layers[c]===!1)continue;let b=o.datasets.get(c),H=a.points[c]??[],W={id:c,markers:H.map(z=>({id:z.id,position:z.position,iconUrl:b?.marker.iconUrl?.(z.entity),element:b?.marker.element?.(z.entity)})),clustering:b?.clustering,onMarkerClick:z=>o.selectPoint(c,z)};h.set(c,u.renderLayer(f,W)),T.add(c)}for(let[c,b]of h)T.has(c)||(b(),h.delete(c))},[o,u,v,a.points,a.layers]),Q(()=>{let f=U.current;return()=>{f.forEach(h=>h()),f.clear()}},[o,u,v]),Q(()=>{if(!l.current||!u)return;let f=l.current,h=!1,T=null;return(async()=>{let c=await u.mount(f,{center:e,zoom:i,fullscreenTarget:d.current??void 0});if(h){u.destroy(c);return}g.current=c,o.setMapHandle(c),T=u.onBoundsChange(c,b=>{D.current?D.current=!1:F.current=!0,o.loadPoints(b)}),E(!0),p.current?.(c.nativeMap??c.raw),o.loadPoints(qt)})(),()=>{h=!0,T?.(),g.current&&(u.destroy(g.current),g.current=null,o.setMapHandle(null),p.current?.(null)),E(!1)}},[o,u]),Q(()=>{let f=g.current;if(!u||!f||e||K.current||F.current)return;let h=[];for(let c of Object.keys(a.points))if(a.layers[c]!==!1)for(let b of a.points[c]??[])h.push(b.position);let T=$t(h);T&&(K.current=!0,D.current=!0,u.fitBounds(f,T))},[u,e,v,a.points,a.layers]),Q(()=>{u?.updateMarkerStates(a.selection,a.hovered)},[u,v,a.selection,a.hovered]);let{Popup:x}=S(),B=x!==he,y=a.points[o.primaryDatasetId]??[],O=a.selection!=null?y.find(f=>f.id===a.selection):void 0,[_,$]=tt(null),A=R(O);return A.current=O,Q(()=>{let f=g.current;if(!u||!f||!B)return;let h=A.current;if(!h)return;let T=u.mountOverlay(h.position);$({entity:h.entity,position:h.position,container:T.container});let c=()=>o.selectPoint(o.primaryDatasetId,null),b=W=>{W.key==="Escape"&&c()};document.addEventListener("keydown",b);let H=u.onMapClick(c);return()=>{document.removeEventListener("keydown",b),H(),T.unmount(),$(null)}},[o,u,v,a.selection,B]),rt("div",{ref:d,className:"relative h-full min-h-0 w-full",children:[rt("div",{ref:l,className:!u&&n?"flex h-full min-h-0 w-full items-center justify-center":"h-full min-h-0 w-full",children:[!u&&n,B&&_?Vt(be(x,{entity:_.entity,onClose:()=>o.selectPoint(o.primaryDatasetId,null)}),_.container):null]}),r!=null&&be("div",{className:"pointer-events-none absolute inset-0",children:be("div",{className:"pointer-events-auto",children:r})})]})}import{jsx as ee,jsxs as jt}from"react/jsx-runtime";var Le="gap";function Wt(t,e){if(t<=7)return Array.from({length:t},(s,o)=>o+1);let i=Math.max(2,e-1),n=Math.min(t-1,e+1),r=[1];i>2&&r.push(Le);for(let s=i;s<=n;s+=1)r.push(s);return n<t-1&&r.push(Le),r.push(t),r}function ot(){let t=L(),{results:e,pagination:i}=C();if(i.mode==="infinite")return e.nextCursor==null?null:ee("button",{type:"button",disabled:i.loading,onClick:()=>{t.loadPage()},children:"Load more"});let n=t.options.pageSize,{pageIndex:r}=i,s=r+1,o=e.total!=null?Math.ceil(e.total/n):null,a=o!=null?s<o:e.nextCursor!=null||e.items.length>=n;if(o!=null?o<=1:r===0&&!a)return null;let p=l=>()=>{t.goToPage(l)};return jt("nav",{className:"rle-pagination","aria-label":"Pagination",children:[ee("button",{type:"button",className:"rle-page-btn rle-page-btn--nav","aria-label":"Previous page",disabled:i.loading||r===0,onClick:p(r-1),children:"\u2039"}),o!=null&&Wt(o,s).map((l,d)=>l===Le?ee("span",{className:"rle-page-ellipsis",children:"\u2026"},`gap-${d}`):ee("button",{type:"button",className:l===s?"rle-page-btn rle-page-btn--active":"rle-page-btn","aria-label":`Page ${l}`,"aria-current":l===s?"page":void 0,disabled:i.loading,onClick:p(l-1),children:l},l)),ee("button",{type:"button",className:"rle-page-btn rle-page-btn--nav","aria-label":"Next page",disabled:i.loading||!a,onClick:p(r+1),children:"\u203A"})]})}import{jsx as Gt}from"react/jsx-runtime";function at(){let{items:t,total:e}=G(),{ResultHeader:i}=S();return Gt(i,{count:t.length,total:e})}import{useEffect as Qt,useRef as Zt}from"react";function lt(t,e){let i=L(),n=Zt(e);n.current=e,Qt(()=>i.on(t,r=>n.current(r)),[i,t])}import{useCallback as Xt,useEffect as dt,useRef as Jt,useState as pt}from"react";import{jsx as Yt}from"react/jsx-runtime";function ut(t){let{children:e,...i}=t,[n]=pt(()=>i),r=Xt(()=>new oe({datasets:n.datasets,filters:n.filters,config:n.config,map:n.map,initialFilters:n.initialFilters,initialResults:n.initialResults,primaryDatasetId:n.primaryDatasetId}),[n]),[s,o]=pt(r),a=Jt(s);a.current=s;let p=i.map;return dt(()=>{p&&s.attachMap(p)},[s,p]),dt(()=>{let l=a.current;return l.isDisposed&&(l=r(),a.current=l,o(l)),n.urlSync&&n.urlSync.start(l),()=>{n.urlSync&&n.urlSync.stop(),l.dispose()}},[n,r]),Yt(ae.Provider,{value:s,children:e})}import{jsx as I,jsxs as te}from"react/jsx-runtime";function ct({view:t,onViewChange:e}){return I("nav",{className:"rle-bottom-nav","aria-label":"Listing navigation",children:te("div",{className:"rle-viewtoggle",role:"group","aria-label":"View",children:[te("button",{type:"button",className:`rle-viewtoggle__btn${t==="list"?" rle-viewtoggle__btn--active":""}`,"aria-pressed":t==="list",onClick:()=>e("list"),children:[I(ei,{}),"List"]}),te("button",{type:"button",className:`rle-viewtoggle__btn${t==="map"?" rle-viewtoggle__btn--active":""}`,"aria-pressed":t==="map",onClick:()=>e("map"),children:[I(ti,{}),"Map"]})]})})}function ei(){return te("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:[I("line",{x1:"8",y1:"6",x2:"20",y2:"6"}),I("line",{x1:"8",y1:"12",x2:"20",y2:"12"}),I("line",{x1:"8",y1:"18",x2:"20",y2:"18"}),I("line",{x1:"4",y1:"6",x2:"4.01",y2:"6"}),I("line",{x1:"4",y1:"12",x2:"4.01",y2:"12"}),I("line",{x1:"4",y1:"18",x2:"4.01",y2:"18"})]})}function ti(){return te("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:[I("polygon",{points:"1 6 8 3 16 6 23 3 23 18 16 21 8 18 1 21 1 6"}),I("line",{x1:"8",y1:"3",x2:"8",y2:"18"}),I("line",{x1:"16",y1:"6",x2:"16",y2:"21"})]})}function Z(t){return typeof t!="number"?t:new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t)}import{Fragment as ni,jsx as N,jsxs as mt}from"react/jsx-runtime";function ii(t){return t?"rle-card rle-card--selected":"rle-card"}function Pe({item:t,selected:e,onSelect:i}){let n=t??{},r=ii(e),s=mt(ni,{children:[n.imageUrl?N("img",{src:n.imageUrl,alt:n.title??"",className:"rle-card-media"}):N("div",{className:"rle-card-media rle-card-media--placeholder","aria-hidden":"true"}),mt("div",{className:"rle-card-body",children:[n.title&&N("span",{className:"rle-card-title",children:n.title}),n.subtitle&&N("span",{className:"rle-card-address",children:n.subtitle}),n.badge&&N("div",{className:"rle-card-info",children:N("span",{className:"rle-card-info-item",children:n.badge})}),n.price!=null&&N("span",{className:"rle-card-price",children:Z(n.price)})]})]});return i?N("button",{type:"button",onClick:i,"aria-pressed":e??!1,className:r,children:s}):N("article",{className:r,children:s})}import{jsx as pe,jsxs as gt}from"react/jsx-runtime";function Te(t){return gt("div",{role:"status",className:"rle-empty",children:[gt("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:[pe("circle",{cx:"11",cy:"11",r:"7"}),pe("path",{d:"m21 21-4.3-4.3"})]}),pe("p",{className:"rle-empty-title",children:"No results"}),pe("p",{className:"rle-empty-hint",children:"Try adjusting your filters or search terms."})]})}import{jsx as ri}from"react/jsx-runtime";function Fe({children:t}){return ri("div",{className:"rle-filter-panel",children:t})}import{jsx as ue,jsxs as si}from"react/jsx-runtime";function we(t){return ue("div",{className:"rle-loading",role:"status","aria-busy":"true","aria-label":"Loading results",children:Array.from({length:3}).map((e,i)=>si("div",{className:"rle-loading-item",children:[ue("div",{className:"rle-skeleton",style:{aspectRatio:"4 / 3",width:"100%"}}),ue("div",{className:"rle-skeleton",style:{height:16,width:"65%"}}),ue("div",{className:"rle-skeleton",style:{height:12,width:"35%"}})]},i))})}import{jsx as oi}from"react/jsx-runtime";function ke({point:t}){let e=t.entity??{};return oi("span",{className:"rle-pin",children:e.price!=null?Z(e.price):""})}import{jsx as X,jsxs as Se}from"react/jsx-runtime";function Ce({entity:t,onClose:e}){let i=t??{};return Se("div",{className:"rle-popup",role:"group","aria-label":"Location details",children:[X("button",{type:"button",onClick:e,"aria-label":"Close",className:"rle-popup-close",children:Se("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:[X("path",{d:"M18 6 6 18"}),X("path",{d:"m6 6 12 12"})]})}),Se("div",{children:[i.title&&X("div",{className:"rle-card-title",children:i.title}),i.subtitle&&X("div",{className:"rle-card-address",children:i.subtitle}),i.price!=null&&X("div",{className:"rle-card-price",children:Z(i.price)})]})]})}import{jsx as ai}from"react/jsx-runtime";function Ie({count:t,total:e}){let i=e!=null&&e!==t?`${t} of ${e} results`:`${t} results`;return ai("div",{className:"rle-result-header",children:i})}import{jsx as li}from"react/jsx-runtime";function Ee({value:t,onChange:e,placeholder:i}){return li("input",{type:"search",value:t,placeholder:i,onChange:n=>e(n.target.value),"aria-label":i??"Search",className:"rle-input"})}import{jsx as di}from"react/jsx-runtime";function xe({children:t}){return di("aside",{className:"rle-sidebar",children:t})}import{jsx as pi}from"react/jsx-runtime";function Re({children:t}){return pi("div",{className:"rle-toolbar",children:t})}var ft={BottomNav:ct,Card:Pe,Marker:ke,Popup:Ce,Sidebar:xe,FilterPanel:Fe,Search:Ee,Empty:Te,Loading:we,ResultHeader:Ie,Toolbar:Re};import{useEffect as Ne,useRef as ui,useState as yt}from"react";import{createPortal as ci}from"react-dom";import{Fragment as gi,jsx as M,jsxs as ce}from"react/jsx-runtime";function ht({open:t,onOpenChange:e,title:i,children:n,footer:r}){let s=ui(null),[o,a]=yt(!1),[p,l]=yt(!1);return Ne(()=>{if(!t){l(!1),a(!1);return}a(!0);let d=requestAnimationFrame(()=>l(!0));return()=>cancelAnimationFrame(d)},[t]),Ne(()=>{if(!o)return;let d=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=d}},[o]),Ne(()=>{if(!o)return;s.current?.focus();function d(g){g.key==="Escape"&&e(!1)}return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[o,e]),!o||typeof document>"u"?null:ci(ce(gi,{children:[M("div",{className:`rle-sheet-backdrop${p?" rle-sheet-backdrop--open":""}`,onClick:()=>e(!1),"aria-hidden":"true"}),ce("div",{ref:s,className:`rle-sheet${p?" rle-sheet--open":""}`,role:"dialog","aria-modal":"true","aria-label":i,tabIndex:-1,children:[M("div",{className:"rle-sheet__handle","aria-hidden":"true"}),ce("div",{className:"rle-sheet__header",children:[i&&M("div",{className:"rle-sheet__title",children:i}),M("button",{type:"button",className:"rle-sheet__close",onClick:()=>e(!1),"aria-label":"Close",children:M(mi,{})})]}),M("div",{className:"rle-sheet__body",children:n}),r&&M("div",{className:"rle-sheet__footer",children:r})]})]}),document.body)}function mi(){return ce("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:[M("path",{d:"M18 6 6 18"}),M("path",{d:"m6 6 12 12"})]})}import{useEffect as ge,useRef as Me,useState as q}from"react";import{jsx as P,jsxs as me}from"react/jsx-runtime";function vt({search:t,onFiltersClick:e,filterCount:i=0,action:n}){let{Search:r}=S();return me("header",{className:"rle-mobile-header",children:[t&&P("div",{className:"rle-mobile-header__search",children:P(r,{value:t.value,onChange:t.onChange,placeholder:t.placeholder})}),me("button",{type:"button",className:"rle-btn rle-mobile-header__btn",onClick:e,children:[P(fi,{}),P("span",{children:"Filters"}),i>0&&P("span",{className:"rle-mobile-header__count",children:i})]}),n&&P("button",{type:"button",className:"rle-btn rle-mobile-header__btn rle-mobile-header__btn--icon",onClick:n.onClick,"aria-label":n.label,children:n.icon??P(yi,{})})]})}function fi(){return me("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:[P("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),P("circle",{cx:"9",cy:"6",r:"2",fill:"currentColor",stroke:"none"}),P("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),P("circle",{cx:"15",cy:"12",r:"2",fill:"currentColor",stroke:"none"}),P("line",{x1:"4",y1:"18",x2:"20",y2:"18"}),P("circle",{cx:"11",cy:"18",r:"2",fill:"currentColor",stroke:"none"})]})}function yi(){return me("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:[P("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),P("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}import{Fragment as bt,jsx as m,jsxs as V}from"react/jsx-runtime";var hi=m("div",{className:"rle-empty",children:"Map unavailable"}),vi=m("div",{className:"rle-map-pending"});function bi(){let t=Me(null),[e,i]=q(!0),[n,r]=q(!0);return ge(()=>{let s=t.current;if(!s)return;let o=()=>{let{clientWidth:g,scrollLeft:v,scrollWidth:E}=s;i(v<=0),r(v+g>=E-1)},a=0,p=()=>{a||(a=requestAnimationFrame(()=>{a=0,o()}))};o(),s.addEventListener("scroll",o,{passive:!0});let l,d;return typeof ResizeObserver<"u"&&(l=new ResizeObserver(o),l.observe(s)),typeof MutationObserver<"u"&&(d=new MutationObserver(p),d.observe(s,{characterData:!0,childList:!0,subtree:!0})),()=>{s.removeEventListener("scroll",o),l?.disconnect(),d?.disconnect(),a&&cancelAnimationFrame(a)}},[]),{atEnd:n,atStart:e,ref:t}}function Li(t,e){if(t===e)return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;let i=t,n=e,r=new Set([...Object.keys(i),...Object.keys(n)]);for(let s of r)if(i[s]!==n[s])return!1;return!0}function Lt({search:t,filterBarStart:e,resultsSlot:i,toolbarEnd:n,mobileAction:r,autoFetch:s=!0,initialPage:o,hasMap:a,mapCenter:p,mapZoom:l,mapControls:d,mapPending:g,onMapReady:v,mobileSheetFooter:E,className:K}){let F=L(),{BottomNav:D,Search:u}=S(),U=G(),{filters:x,set:B}=le(),{pagination:y}=C(),O=a??F.map!=null,[_,$]=q("list"),[A,f]=q(!1),{atEnd:h,atStart:T,ref:c}=bi(),b=Me(null);ge(()=>{y.mode==="paged"&&b.current&&(b.current.scrollTop=0)},[y.mode,y.pageIndex]);let[H,W]=q(x),[z,Tt]=q(A);A!==z&&(Tt(A),A&&W(x));let Be=ye=>W(wt=>({...wt,...ye})),[Oe,_e]=q(!1),fe=Me(!1);ge(()=>{if(Oe){if(y.loading){fe.current=!0;return}fe.current&&(fe.current=!1,_e(!1),f(!1))}},[Oe,y.loading]);let J=t?{value:String(x[t.filterKey]??""),onChange:ye=>{B({[t.filterKey]:ye||void 0})},placeholder:t.placeholder}:void 0;ge(()=>{s!==!1&&(o&&o>0?F.goToPage(o):F.applyFilters({}))},[F,s]);let Ae=()=>{Be(F.filters.clearedParams())},He=()=>{if(Li(H,x)){f(!1);return}_e(!0),F.applyFilters(H)},Ft=F.filters.activeKeys(x).length,ze=U.total??U.items.length;return V("div",{className:K?`rle-app ${K}`:"rle-app",children:[V("div",{className:"rle-filter-bar",children:[V("div",{className:"rle-filter-bar__scroll",ref:c,children:[J&&m("div",{className:"rle-filter-bar__search",children:m(u,{value:J.value,onChange:J.onChange,placeholder:J.placeholder})}),e&&m("div",{className:"rle-filter-bar__slot",children:e}),m(ve,{className:"rle-filters-row",groupClassName:"rle-filter-group",hideLabels:!0})]}),!T&&m("div",{className:"rle-filter-bar__fade rle-filter-bar__fade--start","aria-hidden":"true"}),!h&&m("div",{className:"rle-filter-bar__fade rle-filter-bar__fade--end","aria-hidden":"true"})]}),m(vt,{search:J,onFiltersClick:()=>f(!0),filterCount:Ft,action:r}),V("div",{className:`rle-body ${O?"rle-split":"rle-body--list-only"}`,"data-mobile-view":_,children:[m("div",{className:"rle-list",ref:b,children:i??V(bt,{children:[V("div",{className:"rle-list-header",children:[m(at,{}),n&&m("div",{className:"rle-list-header__toolbar",children:n})]}),m(et,{className:"rle-list-grid"}),m(ot,{})]})}),O&&m("div",{className:"rle-map",children:m(st,{center:p,zoom:l,fallback:g?vi:hi,mapControls:d,onMapReady:v})})]}),O&&m(D,{view:_,onViewChange:$}),m(ht,{title:"Filters",open:A,onOpenChange:f,footer:E?E({draft:H,apply:He,clear:Ae,resultCount:ze,loading:y.loading}):V(bt,{children:[m("button",{type:"button",className:"rle-btn rle-btn--ghost",onClick:Ae,children:"Clear all"}),m("button",{type:"button",className:"rle-btn rle-btn--primary rle-sheet__apply",disabled:y.loading,onClick:He,children:y.loading?m("span",{className:"rle-spinner","aria-label":"Updating results"}):`Show ${ze} results`})]}),children:m(ve,{className:"rle-filter-stack",groupClassName:"rle-filter-group",draft:H,onDraftChange:Be})})]})}import{useEffect as Pi,useRef as Ti,useState as Fi}from"react";import{jsx as De,jsxs as Si}from"react/jsx-runtime";function Pt(t){return"provider"in t}function wi(t){let e=t!=null&&!Pt(t),i=e?t.apiKey:void 0,n=e?t.mapId:void 0,r=e?t.mapOptions:void 0,s=e?t.styles:void 0,o=e?t.overlayMarkers:void 0,[a,p]=Fi(()=>!t||Pt(t)?{ready:!0,provider:t?.provider}:{ready:!1});return Pi(()=>{if(!i)return;let l=!1;return import("./maps/google/index.js").then(({googleProvider:d})=>{l||p({ready:!0,provider:d({apiKey:i,mapId:n,mapOptions:r,styles:s,overlayMarkers:o})})}),()=>{l=!0}},[i,n]),a}function ki({onFiltersChange:t}){let e=Ti(t);return e.current=t,lt("FiltersChanged",i=>{i.type==="FiltersChanged"&&e.current(i.filters)}),null}function Wr(t){let{datasets:e,filters:i,map:n,components:r,initialFilters:s,initialResults:o,onFiltersChange:a,mobileAction:p,search:l,filterBarStart:d,resultsSlot:g,toolbarEnd:v,mapControls:E,onMapReady:K,mobileSheetFooter:F,config:D,autoFetch:u,initialPage:U,className:x}=t,{provider:B}=wi(n),y=[];for(let $ of e)y.push($e($));i&&y.push(We(i)),B&&y.push(qe(B)),s&&y.push(je(s)),o&&y.push(Ge(o)),D&&y.push(Ve(D));let O=Ue(...y),_={...ft,...r};return Si(ut,{...O,children:[a&&De(ki,{onFiltersChange:a}),De(Ze,{..._,children:De(Lt,{className:x,search:l,filterBarStart:d,resultsSlot:g,toolbarEnd:v,mobileAction:p,autoFetch:u??o==null,hasMap:n!=null,mapCenter:n?.center,mapZoom:n?.zoom,mapControls:E,mapPending:n!=null,onMapReady:K,initialPage:U,mobileSheetFooter:F})})]})}export{ie as a,j as b,ne as c,re as d,Ke as e,se as f,oe as g,Ue as h,Ve as i,qe as j,$e as k,We as l,Ki as m,je as n,Ge as o,Ui as p,he as q,Ze as r,S as s,ae as t,L as u,C as v,le as w,ve as x,G as y,et as z,st as A,ot as B,at as C,lt as D,ut as E,ct as F,Pe as G,Te as H,Fe as I,we as J,ke as K,Ce as L,Ie as M,Ee as N,xe as O,Re as P,ft as Q,ht as R,Lt as S,Wr as T};
|
|
@@ -0,0 +1,2 @@
|
|
|
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 ie= (_class =class{__init() {this.listeners=new Set}constructor(e){;_class.prototype.__init.call(this);this.state=this.freezeState({filters:{...e.filters},results:e.results?{items:[...e.results.items],nextCursor:e.results.nextCursor,total:e.results.total}:{items:[],nextCursor:null},bounds:null,selection:null,hovered:null,pagination:{mode:_nullishCoalesce(e.mode, () => ("paged")),loading:!1,loaded:e.results!=null,pageIndex:0},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},pagination:{...this.state.pagination,loaded:!0}})}appendResults(e){this.setState({results:{items:[...this.state.results.items,...e.items],nextCursor:e.nextCursor,total:e.total},pagination:{...this.state.pagination,loaded:!0}})}setBounds(e){this.setState({bounds:e?{...e}:null})}setSelection(e){this.setState({selection:e})}setHovered(e){this.setState({hovered:e})}setLayerVisible(e,i){this.setState({layers:{...this.state.layers,[e]:i}})}setLoading(e){this.setState({pagination:{...this.state.pagination,loading:e}})}setPageIndex(e){this.setState({pagination:{...this.state.pagination,pageIndex: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 j= (_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(),n=e.filter(s=>this.defs.has(s));n.forEach((s,o)=>{this.defs.get(s).order=o});let r=new Set(n);return i.filter(s=>!r.has(s.key)).forEach((s,o)=>{s.order=n.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(n=>Object.hasOwn(e,n.key)).map(n=>n.toParams(e[n.key])).reduce((n,r)=>({...n,...r}),{})}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 ne= (_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 re= (_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 r of[...i])r(e);let n=this.map.get("*");if(n)for(let r of[...n])r(e)}on(e,i){let n=this.map.get(e);return n||(n=new Set,this.map.set(e,n)),n.add(i),()=>{n.delete(i)}}}, _class4);var Ke={pagination:"paged",pageSize:20,debounceMs:250};var se=class{constructor(e){this.options=Object.freeze({...Ke,...e})}};var oe= (_class5 =class{__init5() {this.disposed=!1}__init6() {this.emitter=new re}__init7() {this.debounceTimer=null}__init8() {this.debounceResolve=null}__init9() {this.queryToken=0}__init10() {this.pointsToken=0}__init11() {this.mapHandle=null}__init12() {this.pendingFit=null}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);_class5.prototype.__init10.call(this);_class5.prototype.__init11.call(this);_class5.prototype.__init12.call(this);this.datasets=e.datasets,this.filters=_nullishCoalesce(e.filters, () => (new j)),this.map=e.map,this.config=new se(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 ie({filters:_nullishCoalesce(e.initialFilters, () => ({})),mode:this.config.options.pagination,results:e.initialResults})}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,n=this.config.options.debounceMs;return n<=0?this.runQuery(i):new Promise(r=>{this.debounceResolve=r,this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.debounceResolve=null,r(this.runQuery(i))},n)})}async loadPage(){let e=this.state.results.nextCursor;if(e===null)return;let i=++this.queryToken,n=this.primaryDataset();this.store.setLoading(!0);try{let r=await n.adapter.list(this.currentFilters(),{cursor:e,limit:this.config.options.pageSize});if(i!==this.queryToken)return;this.config.options.pagination==="infinite"?this.store.appendResults(r):this.store.setResults(r),this.emitter.emit({type:"ResultsLoaded",datasetId:this.primaryDatasetId,count:r.items.length})}finally{i===this.queryToken&&this.store.setLoading(!1)}}async goToPage(e){if(e<0)return;let i=++this.queryToken,n=this.primaryDataset();this.store.setLoading(!0);try{let r=await n.adapter.list(this.currentFilters(),{offset:e*this.config.options.pageSize,limit:this.config.options.pageSize});if(i!==this.queryToken)return;this.store.setResults(r),this.store.setPageIndex(e),this.emitter.emit({type:"ResultsLoaded",datasetId:this.primaryDatasetId,count:r.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(),n=++this.pointsToken;await Promise.allSettled(this.datasets.visibleIds().map(async r=>{let s=this.datasets.get(r);if(!s)return;let o=await s.adapter.getPoints(i,e);n===this.pointsToken&&this.store.setPoints(r,o)}))}setMapHandle(e){if(this.mapHandle=e,!e||!this.pendingFit)return;let{bounds:i,options:n}=this.pendingFit;this.pendingFit=null,this.fitBounds(i,n)}fitBounds(e,i){if(this.map){if(!this.mapHandle){this.pendingFit={bounds:e,options:i};return}this.map.fitBounds(this.mapHandle,e,i)}}selectPoint(e,i){this.store.setSelection(i);let n=_optionalChain([this, 'access', _11 => _11.state, 'access', _12 => _12.points, 'access', _13 => _13[e], 'optionalAccess', _14 => _14.find, 'call', _15 => _15(r=>r.id===i)]);n&&this.emitter.emit({type:"PointClicked",datasetId:e,id:n.id,entity:n.entity})}setHovered(e,i){this.store.setHovered(i)}toggleLayer(e){let n=!(_nullishCoalesce(this.state.layers[e], () => (!0)));this.store.setLayerVisible(e,n),this.emitter.emit({type:"LayerToggled",datasetId:e,visible:n})}subscribe(e){return this.store.subscribe(e)}on(e,i){return this.emitter.on(e,i)}get isDisposed(){return this.disposed}attachMap(e){this.disposed||this.map===e||this.map||(this.map=e,this.store.setFilters({}))}dispose(){this.clearDebounce(),this.emitter.dispose(),this.mapHandle=null,this.disposed=!0}async runQuery(e){if(e!==this.queryToken)return;let i=this.primaryDataset();this.store.setLoading(!0);try{let n=await i.adapter.list(this.currentFilters(),{cursor:null,limit:this.config.options.pageSize});if(e!==this.queryToken)return;this.store.setResults(n),this.store.setPageIndex(0),this.emitter.emit({type:"ResultsLoaded",datasetId:this.primaryDatasetId,count:n.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 Ue(...t){let e={config:{},filters:new j,datasets:new ne};for(let i of t)i(e);return e}var Ve=t=>e=>{e.config={...e.config,...t}},qe= exports.j =t=>e=>{e.map=t},$e= exports.k =t=>e=>{e.datasets.add(t)},We= exports.l =t=>e=>{t(e.filters)},Ki= exports.m =t=>e=>{e.urlSync=t},je= exports.n =t=>e=>{e.initialFilters=t},Ge= exports.o =t=>e=>{e.initialResults=t},Ui= exports.p =t=>e=>{e.primaryDatasetId=t};var _react = require('react');var _jsxruntime = require('react/jsx-runtime');function Ct(t){return String(_nullishCoalesce(_optionalChain([t, 'optionalAccess', _16 => _16.title]), () => ("")))}var It=({item:t})=>_jsxruntime.jsx.call(void 0, "div",{children:Ct(t)}),Et=()=>_jsxruntime.jsx.call(void 0, "div",{}),he= exports.q =()=>_jsxruntime.jsx.call(void 0, "div",{}),xt=({children:t})=>_jsxruntime.jsx.call(void 0, "div",{children:t}),Rt=({children:t})=>_jsxruntime.jsx.call(void 0, "div",{children:t}),Nt=({value:t,onChange:e,placeholder:i})=>_jsxruntime.jsx.call(void 0, "input",{type:"search",value:t,placeholder:i,onChange:n=>e(n.target.value),"aria-label":_nullishCoalesce(i, () => ("Search"))}),Mt=()=>_jsxruntime.jsx.call(void 0, "div",{role:"status",children:"No results"}),Dt=()=>_jsxruntime.jsx.call(void 0, "div",{role:"status","aria-busy":"true",children:"Loading\u2026"}),Bt=({count:t})=>_jsxruntime.jsxs.call(void 0, "div",{children:[t," results"]}),Ot=({children:t})=>_jsxruntime.jsx.call(void 0, "div",{children:t}),_t=({view:t,onViewChange:e})=>_jsxruntime.jsxs.call(void 0, "nav",{"aria-label":"Listing navigation",children:[_jsxruntime.jsx.call(void 0, "button",{type:"button","aria-pressed":t==="list",onClick:()=>e("list"),children:"List"}),_jsxruntime.jsx.call(void 0, "button",{type:"button","aria-pressed":t==="map",onClick:()=>e("map"),children:"Map"})]}),w={BottomNav:_t,Card:It,Marker:Et,Popup:he,Sidebar:xt,FilterPanel:Rt,Search:Nt,Empty:Mt,Loading:Dt,ResultHeader:Bt,Toolbar:Ot},Qe=_react.createContext.call(void 0, w);function Ze(t){let{BottomNav:e,Card:i,Marker:n,Popup:r,Sidebar:s,FilterPanel:o,Search:a,Empty:p,Loading:l,ResultHeader:d,Toolbar:g,children:v}=t,E={BottomNav:_nullishCoalesce(e, () => (w.BottomNav)),Card:_nullishCoalesce(i, () => (w.Card)),Marker:_nullishCoalesce(n, () => (w.Marker)),Popup:_nullishCoalesce(r, () => (w.Popup)),Sidebar:_nullishCoalesce(s, () => (w.Sidebar)),FilterPanel:_nullishCoalesce(o, () => (w.FilterPanel)),Search:_nullishCoalesce(a, () => (w.Search)),Empty:_nullishCoalesce(p, () => (w.Empty)),Loading:_nullishCoalesce(l, () => (w.Loading)),ResultHeader:_nullishCoalesce(d, () => (w.ResultHeader)),Toolbar:_nullishCoalesce(g, () => (w.Toolbar))};return _jsxruntime.jsx.call(void 0, Qe.Provider,{value:E,children:v})}function S(){return _react.useContext.call(void 0, Qe)}var ae=_react.createContext.call(void 0, null);function L(){let t=_react.useContext.call(void 0, ae);if(t===null)throw new Error("useListing must be used within a <ListingProvider>");return t}function C(){let t=L(),e=_react.useCallback.call(void 0, n=>t.subscribe(n),[t]),i=_react.useCallback.call(void 0, ()=>t.state,[t]);return _react.useSyncExternalStore.call(void 0, e,i,i)}function le(){let t=L(),e=C(),i=_react.useCallback.call(void 0, r=>t.applyFilters(r),[t]),n=_react.useCallback.call(void 0, (r,s)=>t.applyFilters({[r]:s}),[t]);return{filters:e.filters,set:i,setField:n}}function ve({className:t,groupClassName:e,hideLabels:i,draft:n,onDraftChange:r}={}){let s=L(),{FilterPanel:o}=S(),{filters:a}=le(),p=n!==void 0&&r!==void 0,l=p?n:a;return _jsxruntime.jsx.call(void 0, o,{children:_jsxruntime.jsx.call(void 0, "div",{className:_nullishCoalesce(t, () => ("space-y-5")),children:s.filters.list().map(d=>{if(typeof d.render=="string")return _jsxruntime.jsx.call(void 0, "div",{"data-filter":d.key,className:e},d.key);let g=d.render;return _jsxruntime.jsxs.call(void 0, "div",{className:e,children:[d.label&&!i&&_jsxruntime.jsx.call(void 0, "div",{className:"mb-1.5 text-[13px] font-medium text-foreground",children:d.label}),_jsxruntime.jsx.call(void 0, g,{value:d.fromParams(l),onChange:v=>p?r(d.toParams(v)):void s.applyFilters(d.toParams(v))})]},d.key)})})})}function G(){return C().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 et({className:t}={}){let e=L(),{items:i}=G(),{pagination:n,selection:r}=C(),{Card:s,Empty:o,Loading:a}=S();return i.length===0&&(n.loading||!n.loaded)?_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((p,l)=>{let d=Ut(p,l);return _jsxruntime.jsx.call(void 0, s,{item:p,selected:r===d,onSelect:()=>e.selectPoint(e.primaryDatasetId,d)},d)})})}var _reactdom = require('react-dom');var qt={west:-179.9,south:-85,east:179.9,north:85},it=.1,nt=.02;function $t(t){if(t.length===0)return null;let e=t[0].lng,i=t[0].lng,n=t[0].lat,r=t[0].lat;for(let{lat:a,lng:p}of t)p<e&&(e=p),p>i&&(i=p),a<n&&(n=a),a>r&&(r=a);let s=r>n?(r-n)*it:nt,o=i>e?(i-e)*it:nt;return{west:e-o,east:i+o,south:n-s,north:r+s}}function st(t){let{center:e,zoom:i,fallback:n,mapControls:r,onMapReady:s}=t,o=L(),a=C(),p=_react.useRef.call(void 0, s);p.current=s;let l=_react.useRef.call(void 0, null),d=_react.useRef.call(void 0, null),g=_react.useRef.call(void 0, null),[v,E]=_react.useState.call(void 0, !1),K=_react.useRef.call(void 0, !1),F=_react.useRef.call(void 0, !1),D=_react.useRef.call(void 0, !1),u=o.map,U=_react.useRef.call(void 0, new Map);_react.useEffect.call(void 0, ()=>{let f=g.current;if(!u||!f)return;let h=U.current,T=new Set;for(let c of Object.keys(a.points)){if(a.layers[c]===!1)continue;let b=o.datasets.get(c),H=_nullishCoalesce(a.points[c], () => ([])),W={id:c,markers:H.map(z=>({id:z.id,position:z.position,iconUrl:_optionalChain([b, 'optionalAccess', _17 => _17.marker, 'access', _18 => _18.iconUrl, 'optionalCall', _19 => _19(z.entity)]),element:_optionalChain([b, 'optionalAccess', _20 => _20.marker, 'access', _21 => _21.element, 'optionalCall', _22 => _22(z.entity)])})),clustering:_optionalChain([b, 'optionalAccess', _23 => _23.clustering]),onMarkerClick:z=>o.selectPoint(c,z)};h.set(c,u.renderLayer(f,W)),T.add(c)}for(let[c,b]of h)T.has(c)||(b(),h.delete(c))},[o,u,v,a.points,a.layers]),_react.useEffect.call(void 0, ()=>{let f=U.current;return()=>{f.forEach(h=>h()),f.clear()}},[o,u,v]),_react.useEffect.call(void 0, ()=>{if(!l.current||!u)return;let f=l.current,h=!1,T=null;return(async()=>{let c=await u.mount(f,{center:e,zoom:i,fullscreenTarget:_nullishCoalesce(d.current, () => (void 0))});if(h){u.destroy(c);return}g.current=c,o.setMapHandle(c),T=u.onBoundsChange(c,b=>{D.current?D.current=!1:F.current=!0,o.loadPoints(b)}),E(!0),_optionalChain([p, 'access', _24 => _24.current, 'optionalCall', _25 => _25(_nullishCoalesce(c.nativeMap, () => (c.raw)))]),o.loadPoints(qt)})(),()=>{h=!0,_optionalChain([T, 'optionalCall', _26 => _26()]),g.current&&(u.destroy(g.current),g.current=null,o.setMapHandle(null),_optionalChain([p, 'access', _27 => _27.current, 'optionalCall', _28 => _28(null)])),E(!1)}},[o,u]),_react.useEffect.call(void 0, ()=>{let f=g.current;if(!u||!f||e||K.current||F.current)return;let h=[];for(let c of Object.keys(a.points))if(a.layers[c]!==!1)for(let b of _nullishCoalesce(a.points[c], () => ([])))h.push(b.position);let T=$t(h);T&&(K.current=!0,D.current=!0,u.fitBounds(f,T))},[u,e,v,a.points,a.layers]),_react.useEffect.call(void 0, ()=>{_optionalChain([u, 'optionalAccess', _29 => _29.updateMarkerStates, 'call', _30 => _30(a.selection,a.hovered)])},[u,v,a.selection,a.hovered]);let{Popup:x}=S(),B=x!==he,y=_nullishCoalesce(a.points[o.primaryDatasetId], () => ([])),O=a.selection!=null?y.find(f=>f.id===a.selection):void 0,[_,$]=_react.useState.call(void 0, null),A=_react.useRef.call(void 0, O);return A.current=O,_react.useEffect.call(void 0, ()=>{let f=g.current;if(!u||!f||!B)return;let h=A.current;if(!h)return;let T=u.mountOverlay(h.position);$({entity:h.entity,position:h.position,container:T.container});let c=()=>o.selectPoint(o.primaryDatasetId,null),b=W=>{W.key==="Escape"&&c()};document.addEventListener("keydown",b);let H=u.onMapClick(c);return()=>{document.removeEventListener("keydown",b),H(),T.unmount(),$(null)}},[o,u,v,a.selection,B]),_jsxruntime.jsxs.call(void 0, "div",{ref:d,className:"relative h-full min-h-0 w-full",children:[_jsxruntime.jsxs.call(void 0, "div",{ref:l,className:!u&&n?"flex h-full min-h-0 w-full items-center justify-center":"h-full min-h-0 w-full",children:[!u&&n,B&&_?_reactdom.createPortal.call(void 0, _jsxruntime.jsx.call(void 0, x,{entity:_.entity,onClose:()=>o.selectPoint(o.primaryDatasetId,null)}),_.container):null]}),r!=null&&_jsxruntime.jsx.call(void 0, "div",{className:"pointer-events-none absolute inset-0",children:_jsxruntime.jsx.call(void 0, "div",{className:"pointer-events-auto",children:r})})]})}var Le="gap";function Wt(t,e){if(t<=7)return Array.from({length:t},(s,o)=>o+1);let i=Math.max(2,e-1),n=Math.min(t-1,e+1),r=[1];i>2&&r.push(Le);for(let s=i;s<=n;s+=1)r.push(s);return n<t-1&&r.push(Le),r.push(t),r}function ot(){let t=L(),{results:e,pagination:i}=C();if(i.mode==="infinite")return e.nextCursor==null?null:_jsxruntime.jsx.call(void 0, "button",{type:"button",disabled:i.loading,onClick:()=>{t.loadPage()},children:"Load more"});let n=t.options.pageSize,{pageIndex:r}=i,s=r+1,o=e.total!=null?Math.ceil(e.total/n):null,a=o!=null?s<o:e.nextCursor!=null||e.items.length>=n;if(o!=null?o<=1:r===0&&!a)return null;let p=l=>()=>{t.goToPage(l)};return _jsxruntime.jsxs.call(void 0, "nav",{className:"rle-pagination","aria-label":"Pagination",children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"rle-page-btn rle-page-btn--nav","aria-label":"Previous page",disabled:i.loading||r===0,onClick:p(r-1),children:"\u2039"}),o!=null&&Wt(o,s).map((l,d)=>l===Le?_jsxruntime.jsx.call(void 0, "span",{className:"rle-page-ellipsis",children:"\u2026"},`gap-${d}`):_jsxruntime.jsx.call(void 0, "button",{type:"button",className:l===s?"rle-page-btn rle-page-btn--active":"rle-page-btn","aria-label":`Page ${l}`,"aria-current":l===s?"page":void 0,disabled:i.loading,onClick:p(l-1),children:l},l)),_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"rle-page-btn rle-page-btn--nav","aria-label":"Next page",disabled:i.loading||!a,onClick:p(r+1),children:"\u203A"})]})}function at(){let{items:t,total:e}=G(),{ResultHeader:i}=S();return _jsxruntime.jsx.call(void 0, i,{count:t.length,total:e})}function lt(t,e){let i=L(),n=_react.useRef.call(void 0, e);n.current=e,_react.useEffect.call(void 0, ()=>i.on(t,r=>n.current(r)),[i,t])}function ut(t){let{children:e,...i}=t,[n]=_react.useState.call(void 0, ()=>i),r=_react.useCallback.call(void 0, ()=>new oe({datasets:n.datasets,filters:n.filters,config:n.config,map:n.map,initialFilters:n.initialFilters,initialResults:n.initialResults,primaryDatasetId:n.primaryDatasetId}),[n]),[s,o]=_react.useState.call(void 0, r),a=_react.useRef.call(void 0, s);a.current=s;let p=i.map;return _react.useEffect.call(void 0, ()=>{p&&s.attachMap(p)},[s,p]),_react.useEffect.call(void 0, ()=>{let l=a.current;return l.isDisposed&&(l=r(),a.current=l,o(l)),n.urlSync&&n.urlSync.start(l),()=>{n.urlSync&&n.urlSync.stop(),l.dispose()}},[n,r]),_jsxruntime.jsx.call(void 0, ae.Provider,{value:s,children:e})}function ct({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, ei,{}),"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, ti,{}),"Map"]})]})})}function ei(){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 ti(){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"})]})}function Z(t){return typeof t!="number"?t:new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t)}function ii(t){return t?"rle-card rle-card--selected":"rle-card"}function Pe({item:t,selected:e,onSelect:i}){let n=_nullishCoalesce(t, () => ({})),r=ii(e),s=_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[n.imageUrl?_jsxruntime.jsx.call(void 0, "img",{src:n.imageUrl,alt:_nullishCoalesce(n.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:[n.title&&_jsxruntime.jsx.call(void 0, "span",{className:"rle-card-title",children:n.title}),n.subtitle&&_jsxruntime.jsx.call(void 0, "span",{className:"rle-card-address",children:n.subtitle}),n.badge&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-card-info",children:_jsxruntime.jsx.call(void 0, "span",{className:"rle-card-info-item",children:n.badge})}),n.price!=null&&_jsxruntime.jsx.call(void 0, "span",{className:"rle-card-price",children:Z(n.price)})]})]});return i?_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:i,"aria-pressed":_nullishCoalesce(e, () => (!1)),className:r,children:s}):_jsxruntime.jsx.call(void 0, "article",{className:r,children:s})}function Te(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 Fe({children:t}){return _jsxruntime.jsx.call(void 0, "div",{className:"rle-filter-panel",children:t})}function we(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 ke({point:t}){let e=_nullishCoalesce(t.entity, () => ({}));return _jsxruntime.jsx.call(void 0, "span",{className:"rle-pin",children:e.price!=null?Z(e.price):""})}function Ce({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:Z(i.price)})]})]})}function Ie({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 Ee({value:t,onChange:e,placeholder:i}){return _jsxruntime.jsx.call(void 0, "input",{type:"search",value:t,placeholder:i,onChange:n=>e(n.target.value),"aria-label":_nullishCoalesce(i, () => ("Search")),className:"rle-input"})}function xe({children:t}){return _jsxruntime.jsx.call(void 0, "aside",{className:"rle-sidebar",children:t})}function Re({children:t}){return _jsxruntime.jsx.call(void 0, "div",{className:"rle-toolbar",children:t})}var ft={BottomNav:ct,Card:Pe,Marker:ke,Popup:Ce,Sidebar:xe,FilterPanel:Fe,Search:Ee,Empty:Te,Loading:we,ResultHeader:Ie,Toolbar:Re};function ht({open:t,onOpenChange:e,title:i,children:n,footer:r}){let s=_react.useRef.call(void 0, null),[o,a]=_react.useState.call(void 0, !1),[p,l]=_react.useState.call(void 0, !1);return _react.useEffect.call(void 0, ()=>{if(!t){l(!1),a(!1);return}a(!0);let d=requestAnimationFrame(()=>l(!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', _31 => _31.current, 'optionalAccess', _32 => _32.focus, 'call', _33 => _33()]);function d(g){g.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${p?" rle-sheet-backdrop--open":""}`,onClick:()=>e(!1),"aria-hidden":"true"}),_jsxruntime.jsxs.call(void 0, "div",{ref:s,className:`rle-sheet${p?" 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, mi,{})})]}),_jsxruntime.jsx.call(void 0, "div",{className:"rle-sheet__body",children:n}),r&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-sheet__footer",children:r})]})]}),document.body)}function mi(){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 vt({search:t,onFiltersClick:e,filterCount:i=0,action:n}){let{Search:r}=S();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, r,{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, fi,{}),_jsxruntime.jsx.call(void 0, "span",{children:"Filters"}),i>0&&_jsxruntime.jsx.call(void 0, "span",{className:"rle-mobile-header__count",children:i})]}),n&&_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"rle-btn rle-mobile-header__btn rle-mobile-header__btn--icon",onClick:n.onClick,"aria-label":n.label,children:_nullishCoalesce(n.icon, () => (_jsxruntime.jsx.call(void 0, yi,{})))})]})}function fi(){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 yi(){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 hi=_jsxruntime.jsx.call(void 0, "div",{className:"rle-empty",children:"Map unavailable"}),vi=_jsxruntime.jsx.call(void 0, "div",{className:"rle-map-pending"});function bi(){let t=_react.useRef.call(void 0, null),[e,i]=_react.useState.call(void 0, !0),[n,r]=_react.useState.call(void 0, !0);return _react.useEffect.call(void 0, ()=>{let s=t.current;if(!s)return;let o=()=>{let{clientWidth:g,scrollLeft:v,scrollWidth:E}=s;i(v<=0),r(v+g>=E-1)},a=0,p=()=>{a||(a=requestAnimationFrame(()=>{a=0,o()}))};o(),s.addEventListener("scroll",o,{passive:!0});let l,d;return typeof ResizeObserver<"u"&&(l=new ResizeObserver(o),l.observe(s)),typeof MutationObserver<"u"&&(d=new MutationObserver(p),d.observe(s,{characterData:!0,childList:!0,subtree:!0})),()=>{s.removeEventListener("scroll",o),_optionalChain([l, 'optionalAccess', _34 => _34.disconnect, 'call', _35 => _35()]),_optionalChain([d, 'optionalAccess', _36 => _36.disconnect, 'call', _37 => _37()]),a&&cancelAnimationFrame(a)}},[]),{atEnd:n,atStart:e,ref:t}}function Li(t,e){if(t===e)return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;let i=t,n=e,r=new Set([...Object.keys(i),...Object.keys(n)]);for(let s of r)if(i[s]!==n[s])return!1;return!0}function Lt({search:t,filterBarStart:e,resultsSlot:i,toolbarEnd:n,mobileAction:r,autoFetch:s=!0,initialPage:o,hasMap:a,mapCenter:p,mapZoom:l,mapControls:d,mapPending:g,onMapReady:v,mobileSheetFooter:E,className:K}){let F=L(),{BottomNav:D,Search:u}=S(),U=G(),{filters:x,set:B}=le(),{pagination:y}=C(),O=_nullishCoalesce(a, () => (F.map!=null)),[_,$]=_react.useState.call(void 0, "list"),[A,f]=_react.useState.call(void 0, !1),{atEnd:h,atStart:T,ref:c}=bi(),b=_react.useRef.call(void 0, null);_react.useEffect.call(void 0, ()=>{y.mode==="paged"&&b.current&&(b.current.scrollTop=0)},[y.mode,y.pageIndex]);let[H,W]=_react.useState.call(void 0, x),[z,Tt]=_react.useState.call(void 0, A);A!==z&&(Tt(A),A&&W(x));let Be=ye=>W(wt=>({...wt,...ye})),[Oe,_e]=_react.useState.call(void 0, !1),fe=_react.useRef.call(void 0, !1);_react.useEffect.call(void 0, ()=>{if(Oe){if(y.loading){fe.current=!0;return}fe.current&&(fe.current=!1,_e(!1),f(!1))}},[Oe,y.loading]);let J=t?{value:String(_nullishCoalesce(x[t.filterKey], () => (""))),onChange:ye=>{B({[t.filterKey]:ye||void 0})},placeholder:t.placeholder}:void 0;_react.useEffect.call(void 0, ()=>{s!==!1&&(o&&o>0?F.goToPage(o):F.applyFilters({}))},[F,s]);let Ae=()=>{Be(F.filters.clearedParams())},He=()=>{if(Li(H,x)){f(!1);return}_e(!0),F.applyFilters(H)},Ft=F.filters.activeKeys(x).length,ze=_nullishCoalesce(U.total, () => (U.items.length));return _jsxruntime.jsxs.call(void 0, "div",{className:K?`rle-app ${K}`:"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:c,children:[J&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-filter-bar__search",children:_jsxruntime.jsx.call(void 0, u,{value:J.value,onChange:J.onChange,placeholder:J.placeholder})}),e&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-filter-bar__slot",children:e}),_jsxruntime.jsx.call(void 0, ve,{className:"rle-filters-row",groupClassName:"rle-filter-group",hideLabels:!0})]}),!T&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-filter-bar__fade rle-filter-bar__fade--start","aria-hidden":"true"}),!h&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-filter-bar__fade rle-filter-bar__fade--end","aria-hidden":"true"})]}),_jsxruntime.jsx.call(void 0, vt,{search:J,onFiltersClick:()=>f(!0),filterCount:Ft,action:r}),_jsxruntime.jsxs.call(void 0, "div",{className:`rle-body ${O?"rle-split":"rle-body--list-only"}`,"data-mobile-view":_,children:[_jsxruntime.jsx.call(void 0, "div",{className:"rle-list",ref:b,children:_nullishCoalesce(i, () => (_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsxs.call(void 0, "div",{className:"rle-list-header",children:[_jsxruntime.jsx.call(void 0, at,{}),n&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-list-header__toolbar",children:n})]}),_jsxruntime.jsx.call(void 0, et,{className:"rle-list-grid"}),_jsxruntime.jsx.call(void 0, ot,{})]})))}),O&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-map",children:_jsxruntime.jsx.call(void 0, st,{center:p,zoom:l,fallback:g?vi:hi,mapControls:d,onMapReady:v})})]}),O&&_jsxruntime.jsx.call(void 0, D,{view:_,onViewChange:$}),_jsxruntime.jsx.call(void 0, ht,{title:"Filters",open:A,onOpenChange:f,footer:E?E({draft:H,apply:He,clear:Ae,resultCount:ze,loading:y.loading}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"rle-btn rle-btn--ghost",onClick:Ae,children:"Clear all"}),_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"rle-btn rle-btn--primary rle-sheet__apply",disabled:y.loading,onClick:He,children:y.loading?_jsxruntime.jsx.call(void 0, "span",{className:"rle-spinner","aria-label":"Updating results"}):`Show ${ze} results`})]}),children:_jsxruntime.jsx.call(void 0, ve,{className:"rle-filter-stack",groupClassName:"rle-filter-group",draft:H,onDraftChange:Be})})]})}function Pt(t){return"provider"in t}function wi(t){let e=t!=null&&!Pt(t),i=e?t.apiKey:void 0,n=e?t.mapId:void 0,r=e?t.mapOptions:void 0,s=e?t.styles:void 0,o=e?t.overlayMarkers:void 0,[a,p]=_react.useState.call(void 0, ()=>!t||Pt(t)?{ready:!0,provider:_optionalChain([t, 'optionalAccess', _38 => _38.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:d})=>{l||p({ready:!0,provider:d({apiKey:i,mapId:n,mapOptions:r,styles:s,overlayMarkers:o})})}),()=>{l=!0}},[i,n]),a}function ki({onFiltersChange:t}){let e=_react.useRef.call(void 0, t);return e.current=t,lt("FiltersChanged",i=>{i.type==="FiltersChanged"&&e.current(i.filters)}),null}function Wr(t){let{datasets:e,filters:i,map:n,components:r,initialFilters:s,initialResults:o,onFiltersChange:a,mobileAction:p,search:l,filterBarStart:d,resultsSlot:g,toolbarEnd:v,mapControls:E,onMapReady:K,mobileSheetFooter:F,config:D,autoFetch:u,initialPage:U,className:x}=t,{provider:B}=wi(n),y=[];for(let $ of e)y.push($e($));i&&y.push(We(i)),B&&y.push(qe(B)),s&&y.push(je(s)),o&&y.push(Ge(o)),D&&y.push(Ve(D));let O=Ue(...y),_={...ft,...r};return _jsxruntime.jsxs.call(void 0, ut,{...O,children:[a&&_jsxruntime.jsx.call(void 0, ki,{onFiltersChange:a}),_jsxruntime.jsx.call(void 0, Ze,{..._,children:_jsxruntime.jsx.call(void 0, Lt,{className:x,search:l,filterBarStart:d,resultsSlot:g,toolbarEnd:v,mobileAction:p,autoFetch:_nullishCoalesce(u, () => (o==null)),hasMap:n!=null,mapCenter:_optionalChain([n, 'optionalAccess', _39 => _39.center]),mapZoom:_optionalChain([n, 'optionalAccess', _40 => _40.zoom]),mapControls:E,mapPending:n!=null,onMapReady:K,initialPage:U,mobileSheetFooter:F})})]})}exports.a = ie; exports.b = j; exports.c = ne; exports.d = re; exports.e = Ke; exports.f = se; exports.g = oe; exports.h = Ue; exports.i = Ve; exports.j = qe; exports.k = $e; exports.l = We; exports.m = Ki; exports.n = je; exports.o = Ge; exports.p = Ui; exports.q = he; exports.r = Ze; exports.s = S; exports.t = ae; exports.u = L; exports.v = C; exports.w = le; exports.x = ve; exports.y = G; exports.z = et; exports.A = st; exports.B = ot; exports.C = at; exports.D = lt; exports.E = ut; exports.F = ct; exports.G = Pe; exports.H = Te; exports.I = Fe; exports.J = we; exports.K = ke; exports.L = Ce; exports.M = Ie; exports.N = Ee; exports.O = xe; exports.P = Re; exports.Q = ft; exports.R = ht; exports.S = Lt; exports.T = Wr;
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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;"use client";
|
|
2
|
-
var
|
|
2
|
+
var _chunkXVPGWJW3cjs = require('./chunk-XVPGWJW3.cjs');var b=(r=>(r.Paged="paged",r.Infinite="infinite",r))(b||{});var v=(i=>(i.FiltersChanged="FiltersChanged",i.ResultsLoaded="ResultsLoaded",i.PointClicked="PointClicked",i.BoundsChanged="BoundsChanged",i.LayerToggled="LayerToggled",i))(v||{});var h= (_class =class{__init() {this.listeners=new Set}constructor(t={}){;_class.prototype.__init.call(this);this.query={...t}}getQuery(){return{...this.query}}setQuery(t){this.query={...t},this.notify()}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}notify(){for(let t of[...this.listeners])t()}}, _class);function F(e,t){let r=new Set([...Object.keys(e),...Object.keys(t)]);for(let s of r)if(e[s]!==t[s])return!1;return!0}var f= (_class2 =class{__init2() {this.isSyncing=!1}__init3() {this.unsubscribeEngine=null}__init4() {this.unsubscribeHistory=null}constructor(t){;_class2.prototype.__init2.call(this);_class2.prototype.__init3.call(this);_class2.prototype.__init4.call(this);this.history=t.history,this.toQueryFn=t.toQuery,this.toFiltersFn=t.toFilters,this.hydrateOnStart=_nullishCoalesce(t.hydrateOnStart, () => (!0))}start(t){this.stop(),this.unsubscribeEngine=t.subscribe(()=>{this.isSyncing||this.syncEngineToHistory(t)}),this.unsubscribeHistory=this.history.subscribe(()=>{this.isSyncing||this.withSyncGuard(()=>{this.applyFiltersSafely(t,this.toFiltersFn(this.history.getQuery()))})}),this.hydrateOnStart&&this.withSyncGuard(()=>{this.applyFiltersSafely(t,this.toFiltersFn(this.history.getQuery()))})}stop(){_optionalChain([this, 'access', _ => _.unsubscribeEngine, 'optionalCall', _2 => _2()]),this.unsubscribeEngine=null,_optionalChain([this, 'access', _3 => _3.unsubscribeHistory, 'optionalCall', _4 => _4()]),this.unsubscribeHistory=null}syncEngineToHistory(t){let r=this.toQueryFn(t.state.filters);F(r,this.history.getQuery())||this.withSyncGuard(()=>this.history.setQuery(r))}applyFiltersSafely(t,r){Promise.resolve(t.applyFilters(r)).catch(()=>{})}withSyncGuard(t){this.isSyncing=!0;try{t()}finally{this.isSyncing=!1}}}, _class2);var m=class{constructor(t={}){this.mode=_nullishCoalesce(t.mode, () => ("replace"))}getQuery(){if(typeof window>"u")return{};let t=new URLSearchParams(window.location.search),r={};for(let[s,o]of t)o!==""&&(r[s]=o);return r}setQuery(t){if(typeof window>"u")return;let r=new URLSearchParams;for(let[c,l]of Object.entries(t))l===void 0||l===""||r.set(c,l);let s=r.toString(),o=s?`?${s}`:"";if(o===window.location.search)return;let i=`${window.location.pathname}${o}${window.location.hash}`;this.mode==="push"?window.history.pushState(window.history.state,"",i):window.history.replaceState(window.history.state,"",i)}subscribe(t){return typeof window>"u"?()=>{}:(window.addEventListener("popstate",t),()=>{window.removeEventListener("popstate",t)})}};var _jsxruntime = require('react/jsx-runtime');function it({children:e}){let{Toolbar:t}=_chunkXVPGWJW3cjs.s.call(void 0, );return _jsxruntime.jsx.call(void 0, t,{children:e})}var _react = require('react');function yt(){let e=_chunkXVPGWJW3cjs.u.call(void 0, ),t=_chunkXVPGWJW3cjs.v.call(void 0, ),r=_react.useCallback.call(void 0, n=>e.loadPoints(n),[e]),s=_react.useCallback.call(void 0, (n,p)=>e.selectPoint(n,p),[e]),o=_react.useCallback.call(void 0, n=>e.setHovered(e.primaryDatasetId,n),[e]),i=_react.useCallback.call(void 0, ()=>_optionalChain([e, 'access', _5 => _5.map, 'optionalAccess', _6 => _6.zoomIn, 'call', _7 => _7()]),[e]),c=_react.useCallback.call(void 0, ()=>_optionalChain([e, 'access', _8 => _8.map, 'optionalAccess', _9 => _9.zoomOut, 'call', _10 => _10()]),[e]),l=_react.useCallback.call(void 0, ()=>_optionalChain([e, 'access', _11 => _11.map, 'optionalAccess', _12 => _12.toggleFullscreen, 'call', _13 => _13()]),[e]),g=_react.useCallback.call(void 0, (n,p)=>e.fitBounds(n,p),[e]);return{bounds:t.bounds,points:t.points,hovered:t.hovered,loadPoints:r,selectPoint:s,setHovered:o,zoomIn:i,zoomOut:c,toggleFullscreen:l,fitBounds:g}}function ft(e){let t=_chunkXVPGWJW3cjs.u.call(void 0, ),r=_chunkXVPGWJW3cjs.v.call(void 0, ),s=_react.useCallback.call(void 0, ()=>t.toggleLayer(e),[t,e]);return{visible:_nullishCoalesce(r.layers[e], () => (!0)),points:_nullishCoalesce(r.points[e], () => ([])),toggle:s}}exports.BrowserHistoryPort = m; exports.DatasetRegistry = _chunkXVPGWJW3cjs.c; exports.FallbackPopup = _chunkXVPGWJW3cjs.q; exports.FilterRegistry = _chunkXVPGWJW3cjs.b; exports.ListingApp = _chunkXVPGWJW3cjs.T; exports.ListingComponentsProvider = _chunkXVPGWJW3cjs.r; exports.ListingConfig = _chunkXVPGWJW3cjs.f; exports.ListingEngine = _chunkXVPGWJW3cjs.g; exports.ListingEngineContext = _chunkXVPGWJW3cjs.t; exports.ListingEventType = v; exports.ListingFilters = _chunkXVPGWJW3cjs.x; exports.ListingList = _chunkXVPGWJW3cjs.z; exports.ListingMap = _chunkXVPGWJW3cjs.A; exports.ListingPagination = _chunkXVPGWJW3cjs.B; exports.ListingProvider = _chunkXVPGWJW3cjs.E; exports.ListingResultHeader = _chunkXVPGWJW3cjs.C; exports.ListingStore = _chunkXVPGWJW3cjs.a; exports.ListingToolbar = it; exports.MemoryHistoryPort = h; exports.PaginationMode = b; exports.TypedEmitter = _chunkXVPGWJW3cjs.d; exports.UrlSyncController = f; exports.composeListingProviders = _chunkXVPGWJW3cjs.h; exports.listingDefaultConfig = _chunkXVPGWJW3cjs.e; exports.useListing = _chunkXVPGWJW3cjs.u; exports.useListingComponents = _chunkXVPGWJW3cjs.s; exports.useListingEvent = _chunkXVPGWJW3cjs.D; exports.useListingFilters = _chunkXVPGWJW3cjs.w; exports.useListingLayer = ft; exports.useListingMap = yt; exports.useListingResults = _chunkXVPGWJW3cjs.y; exports.useListingState = _chunkXVPGWJW3cjs.v; exports.withConfig = _chunkXVPGWJW3cjs.i; exports.withDataset = _chunkXVPGWJW3cjs.k; exports.withFilters = _chunkXVPGWJW3cjs.l; exports.withInitialFilters = _chunkXVPGWJW3cjs.n; exports.withInitialResults = _chunkXVPGWJW3cjs.o; exports.withMap = _chunkXVPGWJW3cjs.j; exports.withPrimaryDataset = _chunkXVPGWJW3cjs.p; exports.withUrlSync = _chunkXVPGWJW3cjs.m;
|
package/dist/index.d.cts
CHANGED
|
@@ -613,15 +613,22 @@ interface IListingMapProps {
|
|
|
613
613
|
* rule as `DatasetRegistry.visibleIds()`), looking up each dataset's
|
|
614
614
|
* `MarkerRenderer` via `engine.datasets.get(id)` (see the Step 0 note on
|
|
615
615
|
* `ListingEngine.datasets` in the task report). Each marker's click routes
|
|
616
|
-
* to `engine.selectPoint(datasetId, markerId)`.
|
|
617
|
-
*
|
|
616
|
+
* to `engine.selectPoint(datasetId, markerId)`. The layer is handed to
|
|
617
|
+
* `provider.renderLayer` AGAIN on every change, never torn down first: a
|
|
618
|
+
* provider reconciles a layer id against its previous render (a kept marker
|
|
619
|
+
* keeps its DOM node), so a points reload does not blink the markers. A
|
|
620
|
+
* dataset that stops rendering (gone from `state.points`, hidden via
|
|
621
|
+
* `toggleLayer`) is torn down right there.
|
|
622
|
+
* - Layer-teardown effect (declared SECOND): tears every live layer down when
|
|
623
|
+
* the map goes away (unmount, or a provider/engine change) -- and only then.
|
|
624
|
+
* - Mount effect (declared THIRD): awaits `provider.mount(container, {
|
|
618
625
|
* center, zoom, fullscreenTarget })`, stashes the resulting `MapHandle` in a ref, and wires
|
|
619
626
|
* `provider.onBoundsChange(handle, b => engine.loadPoints(b))`. `fullscreenTarget` is the outer
|
|
620
627
|
* wrapper (`wrapperRef`), not `container` itself -- see "`mapControls`" below for why. Cleanup
|
|
621
628
|
* unsubscribes bounds and calls `provider.destroy(handle)`. Also kicks a
|
|
622
629
|
* one-time, unbounded `engine.loadPoints(WORLD_BOUNDS)` right after the
|
|
623
630
|
* handle is ready -- see "Auto-fit" below for why.
|
|
624
|
-
* - Auto-fit effect (declared
|
|
631
|
+
* - Auto-fit effect (declared FOURTH): frames the map to its own data, once,
|
|
625
632
|
* the first time there is data to frame -- see "Auto-fit" below.
|
|
626
633
|
*
|
|
627
634
|
* ## Auto-fit
|
package/dist/index.d.ts
CHANGED
|
@@ -613,15 +613,22 @@ interface IListingMapProps {
|
|
|
613
613
|
* rule as `DatasetRegistry.visibleIds()`), looking up each dataset's
|
|
614
614
|
* `MarkerRenderer` via `engine.datasets.get(id)` (see the Step 0 note on
|
|
615
615
|
* `ListingEngine.datasets` in the task report). Each marker's click routes
|
|
616
|
-
* to `engine.selectPoint(datasetId, markerId)`.
|
|
617
|
-
*
|
|
616
|
+
* to `engine.selectPoint(datasetId, markerId)`. The layer is handed to
|
|
617
|
+
* `provider.renderLayer` AGAIN on every change, never torn down first: a
|
|
618
|
+
* provider reconciles a layer id against its previous render (a kept marker
|
|
619
|
+
* keeps its DOM node), so a points reload does not blink the markers. A
|
|
620
|
+
* dataset that stops rendering (gone from `state.points`, hidden via
|
|
621
|
+
* `toggleLayer`) is torn down right there.
|
|
622
|
+
* - Layer-teardown effect (declared SECOND): tears every live layer down when
|
|
623
|
+
* the map goes away (unmount, or a provider/engine change) -- and only then.
|
|
624
|
+
* - Mount effect (declared THIRD): awaits `provider.mount(container, {
|
|
618
625
|
* center, zoom, fullscreenTarget })`, stashes the resulting `MapHandle` in a ref, and wires
|
|
619
626
|
* `provider.onBoundsChange(handle, b => engine.loadPoints(b))`. `fullscreenTarget` is the outer
|
|
620
627
|
* wrapper (`wrapperRef`), not `container` itself -- see "`mapControls`" below for why. Cleanup
|
|
621
628
|
* unsubscribes bounds and calls `provider.destroy(handle)`. Also kicks a
|
|
622
629
|
* one-time, unbounded `engine.loadPoints(WORLD_BOUNDS)` right after the
|
|
623
630
|
* handle is ready -- see "Auto-fit" below for why.
|
|
624
|
-
* - Auto-fit effect (declared
|
|
631
|
+
* - Auto-fit effect (declared FOURTH): frames the map to its own data, once,
|
|
625
632
|
* the first time there is data to frame -- see "Auto-fit" below.
|
|
626
633
|
*
|
|
627
634
|
* ## Auto-fit
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{A as V,B as W,C as X,D as Y,E as Z,T as P,a as Q,b as x,c as T,d as L,e as O,f as H,g as E,h as k,i as q,j as B,k as C,l as I,m as U,n as z,o as G,p as R,q as $,r as j,s as d,t as A,u,v as y,w as D,x as J,y as K,z as N}from"./chunk-
|
|
2
|
+
import{A as V,B as W,C as X,D as Y,E as Z,T as P,a as Q,b as x,c as T,d as L,e as O,f as H,g as E,h as k,i as q,j as B,k as C,l as I,m as U,n as z,o as G,p as R,q as $,r as j,s as d,t as A,u,v as y,w as D,x as J,y as K,z as N}from"./chunk-2N3ICJ5L.js";var b=(r=>(r.Paged="paged",r.Infinite="infinite",r))(b||{});var v=(i=>(i.FiltersChanged="FiltersChanged",i.ResultsLoaded="ResultsLoaded",i.PointClicked="PointClicked",i.BoundsChanged="BoundsChanged",i.LayerToggled="LayerToggled",i))(v||{});var h=class{query;listeners=new Set;constructor(t={}){this.query={...t}}getQuery(){return{...this.query}}setQuery(t){this.query={...t},this.notify()}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}notify(){for(let t of[...this.listeners])t()}};function F(e,t){let r=new Set([...Object.keys(e),...Object.keys(t)]);for(let s of r)if(e[s]!==t[s])return!1;return!0}var f=class{history;toQueryFn;toFiltersFn;hydrateOnStart;isSyncing=!1;unsubscribeEngine=null;unsubscribeHistory=null;constructor(t){this.history=t.history,this.toQueryFn=t.toQuery,this.toFiltersFn=t.toFilters,this.hydrateOnStart=t.hydrateOnStart??!0}start(t){this.stop(),this.unsubscribeEngine=t.subscribe(()=>{this.isSyncing||this.syncEngineToHistory(t)}),this.unsubscribeHistory=this.history.subscribe(()=>{this.isSyncing||this.withSyncGuard(()=>{this.applyFiltersSafely(t,this.toFiltersFn(this.history.getQuery()))})}),this.hydrateOnStart&&this.withSyncGuard(()=>{this.applyFiltersSafely(t,this.toFiltersFn(this.history.getQuery()))})}stop(){this.unsubscribeEngine?.(),this.unsubscribeEngine=null,this.unsubscribeHistory?.(),this.unsubscribeHistory=null}syncEngineToHistory(t){let r=this.toQueryFn(t.state.filters);F(r,this.history.getQuery())||this.withSyncGuard(()=>this.history.setQuery(r))}applyFiltersSafely(t,r){Promise.resolve(t.applyFilters(r)).catch(()=>{})}withSyncGuard(t){this.isSyncing=!0;try{t()}finally{this.isSyncing=!1}}};var m=class{mode;constructor(t={}){this.mode=t.mode??"replace"}getQuery(){if(typeof window>"u")return{};let t=new URLSearchParams(window.location.search),r={};for(let[s,o]of t)o!==""&&(r[s]=o);return r}setQuery(t){if(typeof window>"u")return;let r=new URLSearchParams;for(let[c,l]of Object.entries(t))l===void 0||l===""||r.set(c,l);let s=r.toString(),o=s?`?${s}`:"";if(o===window.location.search)return;let i=`${window.location.pathname}${o}${window.location.hash}`;this.mode==="push"?window.history.pushState(window.history.state,"",i):window.history.replaceState(window.history.state,"",i)}subscribe(t){return typeof window>"u"?()=>{}:(window.addEventListener("popstate",t),()=>{window.removeEventListener("popstate",t)})}};import{jsx as w}from"react/jsx-runtime";function it({children:e}){let{Toolbar:t}=d();return w(t,{children:e})}import{useCallback as a}from"react";function yt(){let e=u(),t=y(),r=a(n=>e.loadPoints(n),[e]),s=a((n,p)=>e.selectPoint(n,p),[e]),o=a(n=>e.setHovered(e.primaryDatasetId,n),[e]),i=a(()=>e.map?.zoomIn(),[e]),c=a(()=>e.map?.zoomOut(),[e]),l=a(()=>e.map?.toggleFullscreen(),[e]),g=a((n,p)=>e.fitBounds(n,p),[e]);return{bounds:t.bounds,points:t.points,hovered:t.hovered,loadPoints:r,selectPoint:s,setHovered:o,zoomIn:i,zoomOut:c,toggleFullscreen:l,fitBounds:g}}import{useCallback as S}from"react";function ft(e){let t=u(),r=y(),s=S(()=>t.toggleLayer(e),[t,e]);return{visible:r.layers[e]??!0,points:r.points[e]??[],toggle:s}}export{m as BrowserHistoryPort,T as DatasetRegistry,$ as FallbackPopup,x as FilterRegistry,P as ListingApp,j as ListingComponentsProvider,H as ListingConfig,E as ListingEngine,A as ListingEngineContext,v as ListingEventType,J as ListingFilters,N as ListingList,V as ListingMap,W as ListingPagination,Z as ListingProvider,X as ListingResultHeader,Q as ListingStore,it as ListingToolbar,h as MemoryHistoryPort,b as PaginationMode,L as TypedEmitter,f as UrlSyncController,k as composeListingProviders,O as listingDefaultConfig,u as useListing,d as useListingComponents,Y as useListingEvent,D as useListingFilters,ft as useListingLayer,yt as useListingMap,K as useListingResults,y as useListingState,q as withConfig,C as withDataset,I as withFilters,z as withInitialFilters,G as withInitialResults,B as withMap,R as withPrimaryDataset,U as withUrlSync};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
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; }"use client";
|
|
2
|
-
var _jsapiloader = require('@googlemaps/js-api-loader');var G="DEMO_MAP_ID";function k(e){return e.raw}function W(e,o){if(e.element)return e.element;if(e.iconUrl)return new o.PinElement({glyphSrc:e.iconUrl}).element}var H=12,B="#b3261e";function U(e){if(e.element)return e.element;if(e.iconUrl){let l=document.createElement("img");return l.src=e.iconUrl,l}let o=document.createElement("div");return o.style.width=`${H}px`,o.style.height=`${H}px`,o.style.borderRadius="50%",o.style.backgroundColor=B,o.style.border="2px solid #ffffff",o.style.boxShadow="0 1px 4px rgba(0, 0, 0, 0.4)",o}var L;function V(){if(L)return L;class e extends google.maps.OverlayView{constructor(t,a,i,n){super();e.prototype.__init.call(this);;this.position=t;this.content=a;this.onClick=i;this.lifecycle=n}__init() {this.div=null}onAdd(){let t=document.createElement("div");t.style.position="absolute",t.style.transform="translate(-50%, -50%)",this.onClick&&(t.style.cursor="pointer",t.addEventListener("click",this.onClick)),t.appendChild(this.content),this.div=t,_optionalChain([this, 'access', _2 => _2.getPanes, 'call', _3 => _3(), 'optionalAccess', _4 => _4.overlayMouseTarget, 'access', _5 => _5.appendChild, 'call', _6 => _6(t)]),typeof google.maps.OverlayView.preventMapHitsFrom=="function"&&google.maps.OverlayView.preventMapHitsFrom(t),this.lifecycle.onContainerAdd(t)}draw(){if(!this.div)return;let t=this.getProjection();if(!t)return;let a=t.fromLatLngToDivPixel(new google.maps.LatLng(this.position.lat,this.position.lng));a&&(this.div.style.left=`${a.x}px`,this.div.style.top=`${a.y}px`)}onRemove(){let t=this.div;_optionalChain([this, 'access', _7 => _7.div, 'optionalAccess', _8 => _8.remove, 'call', _9 => _9()]),this.div=null,t&&this.lifecycle.onContainerRemove(t)}}return L=e,L}var E=14,Z=8;function q(e){let{anchorX:o,anchorY:l,popupW:t,popupH:a,mapW:i,mapH:n,offsetY:r,pad:s}=e,c=o-t/2,d=o+t/2,u=0;t>i-s*2?u=s-c:d>i-s?u=i-s-d:c<s&&(u=s-c);let p=l-r-a,m=l+r+a,f=p<s&&m<=n-s;return{dx:u,flipBelow:f}}var b;function Y(){if(b)return b;class e extends google.maps.OverlayView{constructor(t,a,i){super();e.prototype.__init2.call(this);e.prototype.__init3.call(this);;this.container=t;this.position=a;this.mapContainerEl=i}__init2() {this.attached=!1}__init3() {this.clampOffset=null}onAdd(){this.attached=!0,_optionalChain([this, 'access', _10 => _10.getPanes, 'call', _11 => _11(), 'optionalAccess', _12 => _12.floatPane, 'access', _13 => _13.appendChild, 'call', _14 => _14(this.container)]),typeof google.maps.OverlayView.preventMapHitsAndGesturesFrom=="function"&&google.maps.OverlayView.preventMapHitsAndGesturesFrom(this.container),typeof requestAnimationFrame<"u"&&requestAnimationFrame(()=>this.draw())}draw(){let t=this.getProjection();if(!t)return;let a=new google.maps.LatLng(this.position.lat,this.position.lng),i=t.fromLatLngToDivPixel(a);if(!i)return;if(this.clampOffset===null){let s=this.container.offsetWidth,c=this.container.offsetHeight,d=s&&c?t.fromLatLngToContainerPixel(a):null;if(!d){this.container.style.transform="translate(-50%, -100%)",this.container.style.left=`${i.x}px`,this.container.style.top=`${i.y-E}px`;return}this.clampOffset=q({anchorX:d.x,anchorY:d.y,popupW:s,popupH:c,mapW:this.mapContainerEl.clientWidth,mapH:this.mapContainerEl.clientHeight,offsetY:E,pad:Z})}let{dx:n,flipBelow:r}=this.clampOffset;this.container.style.left=`${i.x+n}px`,r?(this.container.style.top=`${i.y+E}px`,this.container.style.transform="translate(-50%, 0)"):(this.container.style.top=`${i.y-E}px`,this.container.style.transform="translate(-50%, -100%)")}onRemove(){this.attached=!1,this.container.remove()}updatePosition(t){(t.lat!==this.position.lat||t.lng!==this.position.lng)&&(this.clampOffset=null),this.position=t,this.attached&&this.draw()}}return b=e,b}function P(e){for(let o of e)typeof o.setMap=="function"?o.setMap(null):o.map=null}var D="#b3261e",X=40,$=64,j=14;function K(e,o){let l=o.count,t=Math.min($,X+Math.round(Math.log10(l+1)*j)),a=document.createElement("div");return a.textContent=String(l),a.style.display="flex",a.style.alignItems="center",a.style.justifyContent="center",a.style.width=`${t}px`,a.style.height=`${t}px`,a.style.borderRadius="50%",a.style.backgroundColor=D,a.style.border="2px solid #ffffff",a.style.boxShadow="0 1px 4px rgba(0, 0, 0, 0.4)",a.style.color="#ffffff",a.style.fontFamily="inherit",a.style.fontWeight="700",a.style.fontSize=t>=52?"15px":"13px",new e.AdvancedMarkerElement({position:o.position,content:a})}var I=!1;async function N(e,o,l,t){let a;try{a=await Promise.resolve().then(() => _interopRequireWildcard(require("@googlemaps/markerclusterer")))}catch(n){I||(I=!0,console.warn('[react-listing-engine] "@googlemaps/markerclusterer" is not installed -- rendering plain (unclustered) markers instead. Install "@googlemaps/markerclusterer" to enable clustering.',n));return}if(e.layers.get(o)!==l)return;let i=new a.MarkerClusterer({map:e.map,markers:l,algorithmOptions:{maxZoom:t.maxZoom},renderer:{render:n=>K(e.markerLib,n)}});e.clusterers.set(o,i)}function x(e,o){let l=e.clusterers.get(o);l&&(l.setMap(null),e.clusterers.delete(o))}var R=!1;function Q(){R||(R=!0,console.warn('[react-listing-engine] Marker clustering is not supported in `styles` (OverlayView) mode -- "@googlemaps/markerclusterer" only manages Marker/AdvancedMarkerElement instances. Rendering plain, unclustered overlay markers instead. Use a `mapId` (advanced-marker mode) to enable clustering.'))}function J(e,o){return o.markers.map(l=>{let t=new e.markerLib.AdvancedMarkerElement({map:e.map,position:l.position,content:W(l,e.markerLib),gmpClickable:!!o.onMarkerClick});if(o.onMarkerClick){let a=o.onMarkerClick;t.addListener("click",()=>a(l.id))}return t})}function T(e,o,l,t){e.classList.toggle("rle-marker--selected",o===l),e.classList.toggle("rle-marker--hovered",o===t&&o!==l)}function ee(e,o){let l=V();return o.markers.map(t=>{let a=o.onMarkerClick,i=a?()=>a(t.id):void 0,n=new l(t.position,U(t),i,{onContainerAdd:r=>{e.markerElements.set(t.id,r),T(r,t.id,e.selectedMarkerId,e.hoveredMarkerId)},onContainerRemove:r=>{e.markerElements.get(t.id)===r&&e.markerElements.delete(t.id)}});return n.setMap(e.map),n})}function A(e,o){let l=e.layerMarkerIds.get(o);if(l){for(let t of l)e.markerElements.delete(t);e.layerMarkerIds.delete(o)}}function te(e){let o=e.getSouthWest(),l=e.getNorthEast();return{west:o.lng(),south:o.lat(),east:l.lng(),north:l.lat()}}var C=256,ne=1.2,re=320,oe=450,ae=2600,F="rle-map-flying";function O(e,o){let l=Math.min(Math.max(Math.sin(e*Math.PI/180),-.9999),.9999);return{x:C*(.5+o/360),y:C*(.5-Math.log((1+l)/(1-l))/(4*Math.PI))}}function S(e){let o=Math.PI-2*Math.PI*e.y/C;return{lat:180/Math.PI*Math.atan(.5*(Math.exp(o)-Math.exp(-o))),lng:(e.x/C-.5)*360}}function se(e,o,l){let t=O(e.north,e.east),a=O(e.south,e.west),i=Math.abs(t.x-a.x),n=Math.abs(t.y-a.y);return i===0||n===0||o===0||l===0?null:{center:S({x:(t.x+a.x)/2,y:(t.y+a.y)/2}),zoom:Math.min(Math.log2(o/i),Math.log2(l/n))}}function ie(e,o,l){let t=l/2**e.zoom,a=l/2**o.zoom,i=o.x-e.x,n=o.y-e.y,r=i*i+n*n,s=ne,c=s*s;if(r<1e-12){let M=Math.abs(Math.log(a/t))/s,g=a<t?-1:1;return{S:M,at:h=>({x:e.x,y:e.y,zoom:Math.log2(l/(t*Math.exp(g*s*(h*M))))})}}let d=Math.sqrt(r),u=(a*a-t*t+c*c*r)/(2*t*c*d),p=(a*a-t*t-c*c*r)/(2*a*c*d),m=Math.log(Math.sqrt(u*u+1)-u),v=(Math.log(Math.sqrt(p*p+1)-p)-m)/s,y=Math.cosh(m);return{S:v,at:M=>{let g=s*(M*v)+m,h=t/(c*d)*(y*Math.tanh(g)-Math.sinh(m)),_=t*y/Math.cosh(g);return{x:e.x+h*i,y:e.y+h*n,zoom:Math.log2(l/_)}}}}function le(e){return e*(2-e)}function ce(e,o,l){let t=performance.now(),a,i=c=>{let d=S(c);typeof e.map.moveCamera=="function"?e.map.moveCamera({center:d,zoom:c.zoom}):(e.map.setZoom(c.zoom),e.map.setCenter(d))},n=()=>{e.containerEl.classList.remove(F),e.containerEl.removeEventListener("pointerdown",r,!0),e.containerEl.removeEventListener("wheel",r,!0)},r=()=>{cancelAnimationFrame(a),n(),e.cancelFlight===r&&(e.cancelFlight=null)},s=()=>{let c=Math.min(1,(performance.now()-t)/l);i(o.at(le(c))),c<1?a=requestAnimationFrame(s):(n(),e.cancelFlight=null)};return e.containerEl.classList.add(F),e.containerEl.addEventListener("pointerdown",r,!0),e.containerEl.addEventListener("wheel",r,!0),a=requestAnimationFrame(s),r}function de(e,o,l){if(typeof ResizeObserver>"u")return;let t=!1,a=()=>{let{width:n,height:r}=e.getBoundingClientRect();n===0||r===0||(google.maps.event.trigger(o,"resize"),t||(t=!0,o.setCenter(l)))},i=new ResizeObserver(a);return i.observe(e),typeof requestAnimationFrame<"u"?requestAnimationFrame(a):queueMicrotask(a),i}function ue(e){if(!e.apiKey)throw new Error("googleProvider: config.apiKey is required (no hardcoded fallback key is ever used).");let o=!1,l=()=>{o||(_jsapiloader.setOptions.call(void 0, {...e.loaderOptions,key:e.apiKey}),o=!0)},t,a=0;return{async mount(i,n){let r=++a;l();let s=await _jsapiloader.importLibrary.call(void 0, "maps"),c=await _jsapiloader.importLibrary.call(void 0, "marker"),d=_nullishCoalesce(n.center, () => ({lat:0,lng:0})),u=e.styles!=null||e.overlayMarkers===!0,p=new s.Map(i,{...e.mapOptions,center:d,zoom:_nullishCoalesce(n.zoom, () => (10)),...u?e.styles!=null?{styles:e.styles}:e.mapId!=null?{mapId:e.mapId}:{}:{mapId:_nullishCoalesce(e.mapId, () => (G))}}),m=de(i,p,d),f={map:p,containerEl:i,fullscreenEl:_nullishCoalesce(n.fullscreenTarget, () => (i)),markerLib:c,markerMode:u?"overlay":"advanced",layers:new Map,clusterers:new Map,boundsListeners:new Set,clickListeners:new Set,resizeObserver:m,markerElements:new Map,layerMarkerIds:new Map,selectedMarkerId:null,hoveredMarkerId:null,cancelFlight:null};return r===a&&(t=f),{raw:f,nativeMap:f.map}},renderLayer(i,n){let r=k(i),s=r.layers.get(n.id);s&&(P(s),r.layers.delete(n.id),A(r,n.id)),x(r,n.id);let c=r.markerMode==="overlay"?ee(r,n):J(r,n);r.layers.set(n.id,c),r.markerMode==="overlay"&&r.layerMarkerIds.set(n.id,n.markers.map(u=>u.id)),n.clustering&&(r.markerMode==="overlay"?Q():N(r,n.id,c,n.clustering));let d=!1;return()=>{d||(d=!0,r.layers.get(n.id)===c&&(P(c),r.layers.delete(n.id),x(r,n.id),A(r,n.id)))}},onBoundsChange(i,n){let r=k(i),s=r.map.addListener("idle",()=>{let d=r.map.getBounds();d&&n(te(d))});r.boundsListeners.add(s);let c=!1;return()=>{c||(c=!0,s.remove(),r.boundsListeners.delete(s))}},onMapClick(i){let n=t;if(!n)return()=>{};let r=n.map.addListener("click",()=>i());n.clickListeners.add(r);let s=!1;return()=>{s||(s=!0,r.remove(),n.clickListeners.delete(r))}},fitBounds(i,n,r){let s=k(i);if(_optionalChain([s, 'access', _15 => _15.cancelFlight, 'optionalCall', _16 => _16()]),s.cancelFlight=null,!_optionalChain([r, 'optionalAccess', _17 => _17.animate])){s.map.fitBounds(n);return}let c=s.map.getZoom(),d=s.map.getCenter(),u=se(n,s.containerEl.clientWidth,s.containerEl.clientHeight);if(c==null||!d||!u){s.map.fitBounds(n);return}let p=typeof s.map.getRenderingType=="function"?s.map.getRenderingType():void 0,m=typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;if(p!=="VECTOR"||m){s.map.fitBounds(n);return}s.map.setOptions({isFractionalZoomEnabled:!0});let f={...O(d.lat(),d.lng()),zoom:c},v={...O(u.center.lat,u.center.lng),zoom:u.zoom},y=Math.max(s.containerEl.clientWidth,s.containerEl.clientHeight),M=ie(f,v,y),g=Math.min(ae,Math.max(oe,M.S*re));s.cancelFlight=ce(s,M,g)},destroy(i){let n=k(i);_optionalChain([n, 'access', _18 => _18.resizeObserver, 'optionalAccess', _19 => _19.disconnect, 'call', _20 => _20()]),_optionalChain([n, 'access', _21 => _21.cancelFlight, 'optionalCall', _22 => _22()]),n.cancelFlight=null;for(let r of n.boundsListeners)r.remove();n.boundsListeners.clear();for(let r of n.clickListeners)r.remove();n.clickListeners.clear();for(let r of[...n.clusterers.keys()])x(n,r);for(let r of n.layers.values())P(r);n.layers.clear(),n.markerElements.clear(),n.layerMarkerIds.clear(),t===n&&(t=void 0)},updateMarkerStates(i,n){if(t){t.selectedMarkerId=i,t.hoveredMarkerId=n;for(let[r,s]of t.markerElements)T(s,r,i,n)}},mountOverlay(i){let n=document.createElement("div");if(n.style.position="absolute",n.style.transform="translate(-50%, -100%)",n.style.pointerEvents="auto",!t)return{container:n,setPosition:()=>{},unmount:()=>n.remove()};let r=Y(),s=new r(n,i,t.containerEl);return s.setMap(t.map),{container:n,setPosition:c=>s.updatePosition(c),unmount:()=>{s.setMap(null),n.remove()}}},zoomIn(){t&&t.map.setZoom((_nullishCoalesce(t.map.getZoom(), () => (0)))+1)},zoomOut(){t&&t.map.setZoom((_nullishCoalesce(t.map.getZoom(), () => (0)))-1)},toggleFullscreen(){if(!t)return;let i=t.fullscreenEl,n=document.fullscreenElement;n!=null&&i.contains(n)?typeof document.exitFullscreen=="function"&&_optionalChain([document, 'access', _23 => _23.exitFullscreen, 'call', _24 => _24(), 'optionalAccess', _25 => _25.catch, 'call', _26 => _26(()=>{})]):typeof i.requestFullscreen=="function"&&_optionalChain([i, 'access', _27 => _27.requestFullscreen, 'call', _28 => _28(), 'optionalAccess', _29 => _29.catch, 'call', _30 => _30(()=>{})])}}}exports.googleProvider = ue;
|
|
2
|
+
var _jsapiloader = require('@googlemaps/js-api-loader');var G="DEMO_MAP_ID";function L(e){return e.raw}function W(e,r){if(e.element)return e.element;if(e.iconUrl)return new r.PinElement({glyphSrc:e.iconUrl}).element}var w=12,B="#b3261e";function I(e){if(e.element)return e.element;if(e.iconUrl){let s=document.createElement("img");return s.src=e.iconUrl,s}let r=document.createElement("div");return r.style.width=`${w}px`,r.style.height=`${w}px`,r.style.borderRadius="50%",r.style.backgroundColor=B,r.style.border="2px solid #ffffff",r.style.boxShadow="0 1px 4px rgba(0, 0, 0, 0.4)",r}var k;function U(){if(k)return k;class e extends google.maps.OverlayView{constructor(t,a,l,n,o){super();e.prototype.__init.call(this);;this.markerId=t;this.position=a;this.content=l;this.lifecycle=o;this.clickHandler=n}__init() {this.div=null}get onClick(){return this.clickHandler}set onClick(t){this.clickHandler=t,this.div&&this.applyCursor(this.div)}getContent(){return this.content}getPosition(){return this.position}setContent(t){t!==this.content&&(this.content=t,_optionalChain([this, 'access', _2 => _2.div, 'optionalAccess', _3 => _3.replaceChildren, 'call', _4 => _4(t)]))}updatePosition(t){this.position=t,this.draw()}applyCursor(t){t.style.cursor=this.clickHandler?"pointer":""}onAdd(){let t=document.createElement("div");t.style.position="absolute",t.style.transform="translate(-50%, -50%)",t.addEventListener("click",()=>_optionalChain([this, 'access', _5 => _5.onClick, 'optionalCall', _6 => _6()])),this.applyCursor(t),t.appendChild(this.content),this.div=t,_optionalChain([this, 'access', _7 => _7.getPanes, 'call', _8 => _8(), 'optionalAccess', _9 => _9.overlayMouseTarget, 'access', _10 => _10.appendChild, 'call', _11 => _11(t)]),typeof google.maps.OverlayView.preventMapHitsFrom=="function"&&google.maps.OverlayView.preventMapHitsFrom(t),this.lifecycle.onContainerAdd(t)}draw(){if(!this.div)return;let t=this.getProjection();if(!t)return;let a=t.fromLatLngToDivPixel(new google.maps.LatLng(this.position.lat,this.position.lng));a&&(this.div.style.left=`${a.x}px`,this.div.style.top=`${a.y}px`)}onRemove(){let t=this.div;_optionalChain([this, 'access', _12 => _12.div, 'optionalAccess', _13 => _13.remove, 'call', _14 => _14()]),this.div=null,t&&this.lifecycle.onContainerRemove(t)}}return k=e,k}var E=14,q=8;function V(e){let{anchorX:r,anchorY:s,popupW:t,popupH:a,mapW:l,mapH:n,offsetY:o,pad:i}=e,c=r-t/2,d=r+t/2,u=0;t>l-i*2?u=i-c:d>l-i?u=l-i-d:c<i&&(u=i-c);let p=s-o-a,m=s+o+a,f=p<i&&m<=n-i;return{dx:u,flipBelow:f}}var b;function Z(){if(b)return b;class e extends google.maps.OverlayView{constructor(t,a,l){super();e.prototype.__init2.call(this);e.prototype.__init3.call(this);;this.container=t;this.position=a;this.mapContainerEl=l}__init2() {this.attached=!1}__init3() {this.clampOffset=null}onAdd(){this.attached=!0,_optionalChain([this, 'access', _15 => _15.getPanes, 'call', _16 => _16(), 'optionalAccess', _17 => _17.floatPane, 'access', _18 => _18.appendChild, 'call', _19 => _19(this.container)]),typeof google.maps.OverlayView.preventMapHitsAndGesturesFrom=="function"&&google.maps.OverlayView.preventMapHitsAndGesturesFrom(this.container),typeof requestAnimationFrame<"u"&&requestAnimationFrame(()=>this.draw())}draw(){let t=this.getProjection();if(!t)return;let a=new google.maps.LatLng(this.position.lat,this.position.lng),l=t.fromLatLngToDivPixel(a);if(!l)return;if(this.clampOffset===null){let i=this.container.offsetWidth,c=this.container.offsetHeight,d=i&&c?t.fromLatLngToContainerPixel(a):null;if(!d){this.container.style.transform="translate(-50%, -100%)",this.container.style.left=`${l.x}px`,this.container.style.top=`${l.y-E}px`;return}this.clampOffset=V({anchorX:d.x,anchorY:d.y,popupW:i,popupH:c,mapW:this.mapContainerEl.clientWidth,mapH:this.mapContainerEl.clientHeight,offsetY:E,pad:q})}let{dx:n,flipBelow:o}=this.clampOffset;this.container.style.left=`${l.x+n}px`,o?(this.container.style.top=`${l.y+E}px`,this.container.style.transform="translate(-50%, 0)"):(this.container.style.top=`${l.y-E}px`,this.container.style.transform="translate(-50%, -100%)")}onRemove(){this.attached=!1,this.container.remove()}updatePosition(t){(t.lat!==this.position.lat||t.lng!==this.position.lng)&&(this.clampOffset=null),this.position=t,this.attached&&this.draw()}}return b=e,b}function P(e){for(let r of e)typeof r.setMap=="function"?r.setMap(null):r.map=null}var Y="#b3261e",D=40,X=64,$=14;function j(e,r){let s=r.count,t=Math.min(X,D+Math.round(Math.log10(s+1)*$)),a=document.createElement("div");return a.textContent=String(s),a.style.display="flex",a.style.alignItems="center",a.style.justifyContent="center",a.style.width=`${t}px`,a.style.height=`${t}px`,a.style.borderRadius="50%",a.style.backgroundColor=Y,a.style.border="2px solid #ffffff",a.style.boxShadow="0 1px 4px rgba(0, 0, 0, 0.4)",a.style.color="#ffffff",a.style.fontFamily="inherit",a.style.fontWeight="700",a.style.fontSize=t>=52?"15px":"13px",new e.AdvancedMarkerElement({position:r.position,content:a})}var R=!1;async function K(e,r,s,t){let a;try{a=await Promise.resolve().then(() => _interopRequireWildcard(require("@googlemaps/markerclusterer")))}catch(n){R||(R=!0,console.warn('[react-listing-engine] "@googlemaps/markerclusterer" is not installed -- rendering plain (unclustered) markers instead. Install "@googlemaps/markerclusterer" to enable clustering.',n));return}if(e.layers.get(r)!==s)return;let l=new a.MarkerClusterer({map:e.map,markers:s,algorithmOptions:{maxZoom:t.maxZoom},renderer:{render:n=>j(e.markerLib,n)}});e.clusterers.set(r,l)}function O(e,r){let s=e.clusterers.get(r);s&&(s.setMap(null),e.clusterers.delete(r))}var T=!1;function N(){T||(T=!0,console.warn('[react-listing-engine] Marker clustering is not supported in `styles` (OverlayView) mode -- "@googlemaps/markerclusterer" only manages Marker/AdvancedMarkerElement instances. Rendering plain, unclustered overlay markers instead. Use a `mapId` (advanced-marker mode) to enable clustering.'))}function Q(e,r){return r.markers.map(s=>{let t=new e.markerLib.AdvancedMarkerElement({map:e.map,position:s.position,content:W(s,e.markerLib),gmpClickable:!!r.onMarkerClick});if(r.onMarkerClick){let a=r.onMarkerClick;t.addListener("click",()=>a(s.id))}return t})}function F(e,r,s,t){e.classList.toggle("rle-marker--selected",r===s),e.classList.toggle("rle-marker--hovered",r===t&&r!==s)}function J(e,r,s){let t=U(),a=new Map;for(let o of _nullishCoalesce(s, () => ([])))a.set(o.markerId,o);let l=new Set,n=r.markers.map(o=>{let i=r.onMarkerClick,c=i?()=>i(o.id):void 0,d=a.get(o.id);if(d&&!l.has(d)){l.add(d),d.onClick=c,te(d.getPosition(),o.position)||d.updatePosition(o.position);let p=I(o);return ne(d.getContent(),p)||d.setContent(p),d}let u=new t(o.id,o.position,I(o),c,ee(e,o.id));return u.setMap(e.map),u});for(let o of _nullishCoalesce(s, () => ([])))l.has(o)||o.setMap(null);return n}function ee(e,r){return{onContainerAdd:s=>{e.markerElements.set(r,s),F(s,r,e.selectedMarkerId,e.hoveredMarkerId)},onContainerRemove:s=>{e.markerElements.get(r)===s&&e.markerElements.delete(r)}}}function te(e,r){return e.lat===r.lat&&e.lng===r.lng}function ne(e,r){return e===r||e.outerHTML===r.outerHTML}function re(e,r){let s=e.layerMarkerIds.get(r);if(s){for(let t of s)e.markerElements.delete(t);e.layerMarkerIds.delete(r)}}function oe(e){let r=e.getSouthWest(),s=e.getNorthEast();return{west:r.lng(),south:r.lat(),east:s.lng(),north:s.lat()}}var C=256,ie=1.2,ae=320,se=450,le=2600,A="rle-map-flying";function H(e,r){let s=Math.min(Math.max(Math.sin(e*Math.PI/180),-.9999),.9999);return{x:C*(.5+r/360),y:C*(.5-Math.log((1+s)/(1-s))/(4*Math.PI))}}function S(e){let r=Math.PI-2*Math.PI*e.y/C;return{lat:180/Math.PI*Math.atan(.5*(Math.exp(r)-Math.exp(-r))),lng:(e.x/C-.5)*360}}function ce(e,r,s){let t=H(e.north,e.east),a=H(e.south,e.west),l=Math.abs(t.x-a.x),n=Math.abs(t.y-a.y);return l===0||n===0||r===0||s===0?null:{center:S({x:(t.x+a.x)/2,y:(t.y+a.y)/2}),zoom:Math.min(Math.log2(r/l),Math.log2(s/n))}}function de(e,r,s){let t=s/2**e.zoom,a=s/2**r.zoom,l=r.x-e.x,n=r.y-e.y,o=l*l+n*n,i=ie,c=i*i;if(o<1e-12){let M=Math.abs(Math.log(a/t))/i,g=a<t?-1:1;return{S:M,at:h=>({x:e.x,y:e.y,zoom:Math.log2(s/(t*Math.exp(g*i*(h*M))))})}}let d=Math.sqrt(o),u=(a*a-t*t+c*c*o)/(2*t*c*d),p=(a*a-t*t-c*c*o)/(2*a*c*d),m=Math.log(Math.sqrt(u*u+1)-u),v=(Math.log(Math.sqrt(p*p+1)-p)-m)/i,y=Math.cosh(m);return{S:v,at:M=>{let g=i*(M*v)+m,h=t/(c*d)*(y*Math.tanh(g)-Math.sinh(m)),_=t*y/Math.cosh(g);return{x:e.x+h*l,y:e.y+h*n,zoom:Math.log2(s/_)}}}}function ue(e){return e*(2-e)}function pe(e,r,s){let t=performance.now(),a,l=c=>{let d=S(c);typeof e.map.moveCamera=="function"?e.map.moveCamera({center:d,zoom:c.zoom}):(e.map.setZoom(c.zoom),e.map.setCenter(d))},n=()=>{e.containerEl.classList.remove(A),e.containerEl.removeEventListener("pointerdown",o,!0),e.containerEl.removeEventListener("wheel",o,!0)},o=()=>{cancelAnimationFrame(a),n(),e.cancelFlight===o&&(e.cancelFlight=null)},i=()=>{let c=Math.min(1,(performance.now()-t)/s);l(r.at(ue(c))),c<1?a=requestAnimationFrame(i):(n(),e.cancelFlight=null)};return e.containerEl.classList.add(A),e.containerEl.addEventListener("pointerdown",o,!0),e.containerEl.addEventListener("wheel",o,!0),a=requestAnimationFrame(i),o}function me(e,r,s){if(typeof ResizeObserver>"u")return;let t=!1,a=()=>{let{width:n,height:o}=e.getBoundingClientRect();n===0||o===0||(google.maps.event.trigger(r,"resize"),t||(t=!0,r.setCenter(s)))},l=new ResizeObserver(a);return l.observe(e),typeof requestAnimationFrame<"u"?requestAnimationFrame(a):queueMicrotask(a),l}function fe(e){if(!e.apiKey)throw new Error("googleProvider: config.apiKey is required (no hardcoded fallback key is ever used).");let r=!1,s=()=>{r||(_jsapiloader.setOptions.call(void 0, {...e.loaderOptions,key:e.apiKey}),r=!0)},t,a=0;return{async mount(l,n){let o=++a;s();let i=await _jsapiloader.importLibrary.call(void 0, "maps"),c=await _jsapiloader.importLibrary.call(void 0, "marker"),d=_nullishCoalesce(n.center, () => ({lat:0,lng:0})),u=e.styles!=null||e.overlayMarkers===!0,p=new i.Map(l,{...e.mapOptions,center:d,zoom:_nullishCoalesce(n.zoom, () => (10)),...u?e.styles!=null?{styles:e.styles}:e.mapId!=null?{mapId:e.mapId}:{}:{mapId:_nullishCoalesce(e.mapId, () => (G))}}),m=me(l,p,d),f={map:p,containerEl:l,fullscreenEl:_nullishCoalesce(n.fullscreenTarget, () => (l)),markerLib:c,markerMode:u?"overlay":"advanced",layers:new Map,clusterers:new Map,boundsListeners:new Set,clickListeners:new Set,resizeObserver:m,markerElements:new Map,layerMarkerIds:new Map,selectedMarkerId:null,hoveredMarkerId:null,cancelFlight:null};return o===a&&(t=f),{raw:f,nativeMap:f.map}},renderLayer(l,n){let o=L(l),i=o.layers.get(n.id),c;o.markerMode==="overlay"?(c=J(o,n,i),o.layers.set(n.id,c),o.layerMarkerIds.set(n.id,n.markers.map(u=>u.id)),n.clustering&&N()):(i&&(P(i),o.layers.delete(n.id)),O(o,n.id),c=Q(o,n),o.layers.set(n.id,c),n.clustering&&K(o,n.id,c,n.clustering));let d=!1;return()=>{d||(d=!0,o.layers.get(n.id)===c&&(P(c),o.layers.delete(n.id),O(o,n.id),re(o,n.id)))}},onBoundsChange(l,n){let o=L(l),i=o.map.addListener("idle",()=>{let d=o.map.getBounds();d&&n(oe(d))});o.boundsListeners.add(i);let c=!1;return()=>{c||(c=!0,i.remove(),o.boundsListeners.delete(i))}},onMapClick(l){let n=t;if(!n)return()=>{};let o=n.map.addListener("click",()=>l());n.clickListeners.add(o);let i=!1;return()=>{i||(i=!0,o.remove(),n.clickListeners.delete(o))}},fitBounds(l,n,o){let i=L(l);if(_optionalChain([i, 'access', _20 => _20.cancelFlight, 'optionalCall', _21 => _21()]),i.cancelFlight=null,!_optionalChain([o, 'optionalAccess', _22 => _22.animate])){i.map.fitBounds(n);return}let c=i.map.getZoom(),d=i.map.getCenter(),u=ce(n,i.containerEl.clientWidth,i.containerEl.clientHeight);if(c==null||!d||!u){i.map.fitBounds(n);return}let p=typeof i.map.getRenderingType=="function"?i.map.getRenderingType():void 0,m=typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;if(p!=="VECTOR"||m){i.map.fitBounds(n);return}i.map.setOptions({isFractionalZoomEnabled:!0});let f={...H(d.lat(),d.lng()),zoom:c},v={...H(u.center.lat,u.center.lng),zoom:u.zoom},y=Math.max(i.containerEl.clientWidth,i.containerEl.clientHeight),M=de(f,v,y),g=Math.min(le,Math.max(se,M.S*ae));i.cancelFlight=pe(i,M,g)},destroy(l){let n=L(l);_optionalChain([n, 'access', _23 => _23.resizeObserver, 'optionalAccess', _24 => _24.disconnect, 'call', _25 => _25()]),_optionalChain([n, 'access', _26 => _26.cancelFlight, 'optionalCall', _27 => _27()]),n.cancelFlight=null;for(let o of n.boundsListeners)o.remove();n.boundsListeners.clear();for(let o of n.clickListeners)o.remove();n.clickListeners.clear();for(let o of[...n.clusterers.keys()])O(n,o);for(let o of n.layers.values())P(o);n.layers.clear(),n.markerElements.clear(),n.layerMarkerIds.clear(),t===n&&(t=void 0)},updateMarkerStates(l,n){if(t){t.selectedMarkerId=l,t.hoveredMarkerId=n;for(let[o,i]of t.markerElements)F(i,o,l,n)}},mountOverlay(l){let n=document.createElement("div");if(n.style.position="absolute",n.style.transform="translate(-50%, -100%)",n.style.pointerEvents="auto",!t)return{container:n,setPosition:()=>{},unmount:()=>n.remove()};let o=Z(),i=new o(n,l,t.containerEl);return i.setMap(t.map),{container:n,setPosition:c=>i.updatePosition(c),unmount:()=>{i.setMap(null),n.remove()}}},zoomIn(){t&&t.map.setZoom((_nullishCoalesce(t.map.getZoom(), () => (0)))+1)},zoomOut(){t&&t.map.setZoom((_nullishCoalesce(t.map.getZoom(), () => (0)))-1)},toggleFullscreen(){if(!t)return;let l=t.fullscreenEl,n=document.fullscreenElement;n!=null&&l.contains(n)?typeof document.exitFullscreen=="function"&&_optionalChain([document, 'access', _28 => _28.exitFullscreen, 'call', _29 => _29(), 'optionalAccess', _30 => _30.catch, 'call', _31 => _31(()=>{})]):typeof l.requestFullscreen=="function"&&_optionalChain([l, 'access', _32 => _32.requestFullscreen, 'call', _33 => _33(), 'optionalAccess', _34 => _34.catch, 'call', _35 => _35(()=>{})])}}}exports.googleProvider = fe;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{importLibrary as w,setOptions as z}from"@googlemaps/js-api-loader";var G="DEMO_MAP_ID";function k(e){return e.raw}function W(e,o){if(e.element)return e.element;if(e.iconUrl)return new o.PinElement({glyphSrc:e.iconUrl}).element}var H=12,B="#b3261e";function U(e){if(e.element)return e.element;if(e.iconUrl){let l=document.createElement("img");return l.src=e.iconUrl,l}let o=document.createElement("div");return o.style.width=`${H}px`,o.style.height=`${H}px`,o.style.borderRadius="50%",o.style.backgroundColor=B,o.style.border="2px solid #ffffff",o.style.boxShadow="0 1px 4px rgba(0, 0, 0, 0.4)",o}var L;function V(){if(L)return L;class e extends google.maps.OverlayView{constructor(t,a,i,n){super();this.position=t;this.content=a;this.onClick=i;this.lifecycle=n}position;content;onClick;lifecycle;div=null;onAdd(){let t=document.createElement("div");t.style.position="absolute",t.style.transform="translate(-50%, -50%)",this.onClick&&(t.style.cursor="pointer",t.addEventListener("click",this.onClick)),t.appendChild(this.content),this.div=t,this.getPanes()?.overlayMouseTarget.appendChild(t),typeof google.maps.OverlayView.preventMapHitsFrom=="function"&&google.maps.OverlayView.preventMapHitsFrom(t),this.lifecycle.onContainerAdd(t)}draw(){if(!this.div)return;let t=this.getProjection();if(!t)return;let a=t.fromLatLngToDivPixel(new google.maps.LatLng(this.position.lat,this.position.lng));a&&(this.div.style.left=`${a.x}px`,this.div.style.top=`${a.y}px`)}onRemove(){let t=this.div;this.div?.remove(),this.div=null,t&&this.lifecycle.onContainerRemove(t)}}return L=e,L}var E=14,Z=8;function q(e){let{anchorX:o,anchorY:l,popupW:t,popupH:a,mapW:i,mapH:n,offsetY:r,pad:s}=e,c=o-t/2,d=o+t/2,u=0;t>i-s*2?u=s-c:d>i-s?u=i-s-d:c<s&&(u=s-c);let p=l-r-a,m=l+r+a,f=p<s&&m<=n-s;return{dx:u,flipBelow:f}}var b;function Y(){if(b)return b;class e extends google.maps.OverlayView{constructor(t,a,i){super();this.container=t;this.position=a;this.mapContainerEl=i}container;position;mapContainerEl;attached=!1;clampOffset=null;onAdd(){this.attached=!0,this.getPanes()?.floatPane.appendChild(this.container),typeof google.maps.OverlayView.preventMapHitsAndGesturesFrom=="function"&&google.maps.OverlayView.preventMapHitsAndGesturesFrom(this.container),typeof requestAnimationFrame<"u"&&requestAnimationFrame(()=>this.draw())}draw(){let t=this.getProjection();if(!t)return;let a=new google.maps.LatLng(this.position.lat,this.position.lng),i=t.fromLatLngToDivPixel(a);if(!i)return;if(this.clampOffset===null){let s=this.container.offsetWidth,c=this.container.offsetHeight,d=s&&c?t.fromLatLngToContainerPixel(a):null;if(!d){this.container.style.transform="translate(-50%, -100%)",this.container.style.left=`${i.x}px`,this.container.style.top=`${i.y-E}px`;return}this.clampOffset=q({anchorX:d.x,anchorY:d.y,popupW:s,popupH:c,mapW:this.mapContainerEl.clientWidth,mapH:this.mapContainerEl.clientHeight,offsetY:E,pad:Z})}let{dx:n,flipBelow:r}=this.clampOffset;this.container.style.left=`${i.x+n}px`,r?(this.container.style.top=`${i.y+E}px`,this.container.style.transform="translate(-50%, 0)"):(this.container.style.top=`${i.y-E}px`,this.container.style.transform="translate(-50%, -100%)")}onRemove(){this.attached=!1,this.container.remove()}updatePosition(t){(t.lat!==this.position.lat||t.lng!==this.position.lng)&&(this.clampOffset=null),this.position=t,this.attached&&this.draw()}}return b=e,b}function P(e){for(let o of e)typeof o.setMap=="function"?o.setMap(null):o.map=null}var D="#b3261e",X=40,$=64,j=14;function K(e,o){let l=o.count,t=Math.min($,X+Math.round(Math.log10(l+1)*j)),a=document.createElement("div");return a.textContent=String(l),a.style.display="flex",a.style.alignItems="center",a.style.justifyContent="center",a.style.width=`${t}px`,a.style.height=`${t}px`,a.style.borderRadius="50%",a.style.backgroundColor=D,a.style.border="2px solid #ffffff",a.style.boxShadow="0 1px 4px rgba(0, 0, 0, 0.4)",a.style.color="#ffffff",a.style.fontFamily="inherit",a.style.fontWeight="700",a.style.fontSize=t>=52?"15px":"13px",new e.AdvancedMarkerElement({position:o.position,content:a})}var I=!1;async function N(e,o,l,t){let a;try{a=await import("@googlemaps/markerclusterer")}catch(n){I||(I=!0,console.warn('[react-listing-engine] "@googlemaps/markerclusterer" is not installed -- rendering plain (unclustered) markers instead. Install "@googlemaps/markerclusterer" to enable clustering.',n));return}if(e.layers.get(o)!==l)return;let i=new a.MarkerClusterer({map:e.map,markers:l,algorithmOptions:{maxZoom:t.maxZoom},renderer:{render:n=>K(e.markerLib,n)}});e.clusterers.set(o,i)}function x(e,o){let l=e.clusterers.get(o);l&&(l.setMap(null),e.clusterers.delete(o))}var R=!1;function Q(){R||(R=!0,console.warn('[react-listing-engine] Marker clustering is not supported in `styles` (OverlayView) mode -- "@googlemaps/markerclusterer" only manages Marker/AdvancedMarkerElement instances. Rendering plain, unclustered overlay markers instead. Use a `mapId` (advanced-marker mode) to enable clustering.'))}function J(e,o){return o.markers.map(l=>{let t=new e.markerLib.AdvancedMarkerElement({map:e.map,position:l.position,content:W(l,e.markerLib),gmpClickable:!!o.onMarkerClick});if(o.onMarkerClick){let a=o.onMarkerClick;t.addListener("click",()=>a(l.id))}return t})}function T(e,o,l,t){e.classList.toggle("rle-marker--selected",o===l),e.classList.toggle("rle-marker--hovered",o===t&&o!==l)}function ee(e,o){let l=V();return o.markers.map(t=>{let a=o.onMarkerClick,i=a?()=>a(t.id):void 0,n=new l(t.position,U(t),i,{onContainerAdd:r=>{e.markerElements.set(t.id,r),T(r,t.id,e.selectedMarkerId,e.hoveredMarkerId)},onContainerRemove:r=>{e.markerElements.get(t.id)===r&&e.markerElements.delete(t.id)}});return n.setMap(e.map),n})}function A(e,o){let l=e.layerMarkerIds.get(o);if(l){for(let t of l)e.markerElements.delete(t);e.layerMarkerIds.delete(o)}}function te(e){let o=e.getSouthWest(),l=e.getNorthEast();return{west:o.lng(),south:o.lat(),east:l.lng(),north:l.lat()}}var C=256,ne=1.2,re=320,oe=450,ae=2600,F="rle-map-flying";function O(e,o){let l=Math.min(Math.max(Math.sin(e*Math.PI/180),-.9999),.9999);return{x:C*(.5+o/360),y:C*(.5-Math.log((1+l)/(1-l))/(4*Math.PI))}}function S(e){let o=Math.PI-2*Math.PI*e.y/C;return{lat:180/Math.PI*Math.atan(.5*(Math.exp(o)-Math.exp(-o))),lng:(e.x/C-.5)*360}}function se(e,o,l){let t=O(e.north,e.east),a=O(e.south,e.west),i=Math.abs(t.x-a.x),n=Math.abs(t.y-a.y);return i===0||n===0||o===0||l===0?null:{center:S({x:(t.x+a.x)/2,y:(t.y+a.y)/2}),zoom:Math.min(Math.log2(o/i),Math.log2(l/n))}}function ie(e,o,l){let t=l/2**e.zoom,a=l/2**o.zoom,i=o.x-e.x,n=o.y-e.y,r=i*i+n*n,s=ne,c=s*s;if(r<1e-12){let M=Math.abs(Math.log(a/t))/s,g=a<t?-1:1;return{S:M,at:h=>({x:e.x,y:e.y,zoom:Math.log2(l/(t*Math.exp(g*s*(h*M))))})}}let d=Math.sqrt(r),u=(a*a-t*t+c*c*r)/(2*t*c*d),p=(a*a-t*t-c*c*r)/(2*a*c*d),m=Math.log(Math.sqrt(u*u+1)-u),v=(Math.log(Math.sqrt(p*p+1)-p)-m)/s,y=Math.cosh(m);return{S:v,at:M=>{let g=s*(M*v)+m,h=t/(c*d)*(y*Math.tanh(g)-Math.sinh(m)),_=t*y/Math.cosh(g);return{x:e.x+h*i,y:e.y+h*n,zoom:Math.log2(l/_)}}}}function le(e){return e*(2-e)}function ce(e,o,l){let t=performance.now(),a,i=c=>{let d=S(c);typeof e.map.moveCamera=="function"?e.map.moveCamera({center:d,zoom:c.zoom}):(e.map.setZoom(c.zoom),e.map.setCenter(d))},n=()=>{e.containerEl.classList.remove(F),e.containerEl.removeEventListener("pointerdown",r,!0),e.containerEl.removeEventListener("wheel",r,!0)},r=()=>{cancelAnimationFrame(a),n(),e.cancelFlight===r&&(e.cancelFlight=null)},s=()=>{let c=Math.min(1,(performance.now()-t)/l);i(o.at(le(c))),c<1?a=requestAnimationFrame(s):(n(),e.cancelFlight=null)};return e.containerEl.classList.add(F),e.containerEl.addEventListener("pointerdown",r,!0),e.containerEl.addEventListener("wheel",r,!0),a=requestAnimationFrame(s),r}function de(e,o,l){if(typeof ResizeObserver>"u")return;let t=!1,a=()=>{let{width:n,height:r}=e.getBoundingClientRect();n===0||r===0||(google.maps.event.trigger(o,"resize"),t||(t=!0,o.setCenter(l)))},i=new ResizeObserver(a);return i.observe(e),typeof requestAnimationFrame<"u"?requestAnimationFrame(a):queueMicrotask(a),i}function ue(e){if(!e.apiKey)throw new Error("googleProvider: config.apiKey is required (no hardcoded fallback key is ever used).");let o=!1,l=()=>{o||(z({...e.loaderOptions,key:e.apiKey}),o=!0)},t,a=0;return{async mount(i,n){let r=++a;l();let s=await w("maps"),c=await w("marker"),d=n.center??{lat:0,lng:0},u=e.styles!=null||e.overlayMarkers===!0,p=new s.Map(i,{...e.mapOptions,center:d,zoom:n.zoom??10,...u?e.styles!=null?{styles:e.styles}:e.mapId!=null?{mapId:e.mapId}:{}:{mapId:e.mapId??G}}),m=de(i,p,d),f={map:p,containerEl:i,fullscreenEl:n.fullscreenTarget??i,markerLib:c,markerMode:u?"overlay":"advanced",layers:new Map,clusterers:new Map,boundsListeners:new Set,clickListeners:new Set,resizeObserver:m,markerElements:new Map,layerMarkerIds:new Map,selectedMarkerId:null,hoveredMarkerId:null,cancelFlight:null};return r===a&&(t=f),{raw:f,nativeMap:f.map}},renderLayer(i,n){let r=k(i),s=r.layers.get(n.id);s&&(P(s),r.layers.delete(n.id),A(r,n.id)),x(r,n.id);let c=r.markerMode==="overlay"?ee(r,n):J(r,n);r.layers.set(n.id,c),r.markerMode==="overlay"&&r.layerMarkerIds.set(n.id,n.markers.map(u=>u.id)),n.clustering&&(r.markerMode==="overlay"?Q():N(r,n.id,c,n.clustering));let d=!1;return()=>{d||(d=!0,r.layers.get(n.id)===c&&(P(c),r.layers.delete(n.id),x(r,n.id),A(r,n.id)))}},onBoundsChange(i,n){let r=k(i),s=r.map.addListener("idle",()=>{let d=r.map.getBounds();d&&n(te(d))});r.boundsListeners.add(s);let c=!1;return()=>{c||(c=!0,s.remove(),r.boundsListeners.delete(s))}},onMapClick(i){let n=t;if(!n)return()=>{};let r=n.map.addListener("click",()=>i());n.clickListeners.add(r);let s=!1;return()=>{s||(s=!0,r.remove(),n.clickListeners.delete(r))}},fitBounds(i,n,r){let s=k(i);if(s.cancelFlight?.(),s.cancelFlight=null,!r?.animate){s.map.fitBounds(n);return}let c=s.map.getZoom(),d=s.map.getCenter(),u=se(n,s.containerEl.clientWidth,s.containerEl.clientHeight);if(c==null||!d||!u){s.map.fitBounds(n);return}let p=typeof s.map.getRenderingType=="function"?s.map.getRenderingType():void 0,m=typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;if(p!=="VECTOR"||m){s.map.fitBounds(n);return}s.map.setOptions({isFractionalZoomEnabled:!0});let f={...O(d.lat(),d.lng()),zoom:c},v={...O(u.center.lat,u.center.lng),zoom:u.zoom},y=Math.max(s.containerEl.clientWidth,s.containerEl.clientHeight),M=ie(f,v,y),g=Math.min(ae,Math.max(oe,M.S*re));s.cancelFlight=ce(s,M,g)},destroy(i){let n=k(i);n.resizeObserver?.disconnect(),n.cancelFlight?.(),n.cancelFlight=null;for(let r of n.boundsListeners)r.remove();n.boundsListeners.clear();for(let r of n.clickListeners)r.remove();n.clickListeners.clear();for(let r of[...n.clusterers.keys()])x(n,r);for(let r of n.layers.values())P(r);n.layers.clear(),n.markerElements.clear(),n.layerMarkerIds.clear(),t===n&&(t=void 0)},updateMarkerStates(i,n){if(t){t.selectedMarkerId=i,t.hoveredMarkerId=n;for(let[r,s]of t.markerElements)T(s,r,i,n)}},mountOverlay(i){let n=document.createElement("div");if(n.style.position="absolute",n.style.transform="translate(-50%, -100%)",n.style.pointerEvents="auto",!t)return{container:n,setPosition:()=>{},unmount:()=>n.remove()};let r=Y(),s=new r(n,i,t.containerEl);return s.setMap(t.map),{container:n,setPosition:c=>s.updatePosition(c),unmount:()=>{s.setMap(null),n.remove()}}},zoomIn(){t&&t.map.setZoom((t.map.getZoom()??0)+1)},zoomOut(){t&&t.map.setZoom((t.map.getZoom()??0)-1)},toggleFullscreen(){if(!t)return;let i=t.fullscreenEl,n=document.fullscreenElement;n!=null&&i.contains(n)?typeof document.exitFullscreen=="function"&&document.exitFullscreen()?.catch(()=>{}):typeof i.requestFullscreen=="function"&&i.requestFullscreen()?.catch(()=>{})}}}export{ue as googleProvider};
|
|
2
|
+
import{importLibrary as x,setOptions as z}from"@googlemaps/js-api-loader";var G="DEMO_MAP_ID";function L(e){return e.raw}function W(e,r){if(e.element)return e.element;if(e.iconUrl)return new r.PinElement({glyphSrc:e.iconUrl}).element}var w=12,B="#b3261e";function I(e){if(e.element)return e.element;if(e.iconUrl){let s=document.createElement("img");return s.src=e.iconUrl,s}let r=document.createElement("div");return r.style.width=`${w}px`,r.style.height=`${w}px`,r.style.borderRadius="50%",r.style.backgroundColor=B,r.style.border="2px solid #ffffff",r.style.boxShadow="0 1px 4px rgba(0, 0, 0, 0.4)",r}var k;function U(){if(k)return k;class e extends google.maps.OverlayView{constructor(t,a,l,n,o){super();this.markerId=t;this.position=a;this.content=l;this.lifecycle=o;this.clickHandler=n}markerId;position;content;lifecycle;div=null;clickHandler;get onClick(){return this.clickHandler}set onClick(t){this.clickHandler=t,this.div&&this.applyCursor(this.div)}getContent(){return this.content}getPosition(){return this.position}setContent(t){t!==this.content&&(this.content=t,this.div?.replaceChildren(t))}updatePosition(t){this.position=t,this.draw()}applyCursor(t){t.style.cursor=this.clickHandler?"pointer":""}onAdd(){let t=document.createElement("div");t.style.position="absolute",t.style.transform="translate(-50%, -50%)",t.addEventListener("click",()=>this.onClick?.()),this.applyCursor(t),t.appendChild(this.content),this.div=t,this.getPanes()?.overlayMouseTarget.appendChild(t),typeof google.maps.OverlayView.preventMapHitsFrom=="function"&&google.maps.OverlayView.preventMapHitsFrom(t),this.lifecycle.onContainerAdd(t)}draw(){if(!this.div)return;let t=this.getProjection();if(!t)return;let a=t.fromLatLngToDivPixel(new google.maps.LatLng(this.position.lat,this.position.lng));a&&(this.div.style.left=`${a.x}px`,this.div.style.top=`${a.y}px`)}onRemove(){let t=this.div;this.div?.remove(),this.div=null,t&&this.lifecycle.onContainerRemove(t)}}return k=e,k}var E=14,q=8;function V(e){let{anchorX:r,anchorY:s,popupW:t,popupH:a,mapW:l,mapH:n,offsetY:o,pad:i}=e,c=r-t/2,d=r+t/2,u=0;t>l-i*2?u=i-c:d>l-i?u=l-i-d:c<i&&(u=i-c);let p=s-o-a,m=s+o+a,f=p<i&&m<=n-i;return{dx:u,flipBelow:f}}var b;function Z(){if(b)return b;class e extends google.maps.OverlayView{constructor(t,a,l){super();this.container=t;this.position=a;this.mapContainerEl=l}container;position;mapContainerEl;attached=!1;clampOffset=null;onAdd(){this.attached=!0,this.getPanes()?.floatPane.appendChild(this.container),typeof google.maps.OverlayView.preventMapHitsAndGesturesFrom=="function"&&google.maps.OverlayView.preventMapHitsAndGesturesFrom(this.container),typeof requestAnimationFrame<"u"&&requestAnimationFrame(()=>this.draw())}draw(){let t=this.getProjection();if(!t)return;let a=new google.maps.LatLng(this.position.lat,this.position.lng),l=t.fromLatLngToDivPixel(a);if(!l)return;if(this.clampOffset===null){let i=this.container.offsetWidth,c=this.container.offsetHeight,d=i&&c?t.fromLatLngToContainerPixel(a):null;if(!d){this.container.style.transform="translate(-50%, -100%)",this.container.style.left=`${l.x}px`,this.container.style.top=`${l.y-E}px`;return}this.clampOffset=V({anchorX:d.x,anchorY:d.y,popupW:i,popupH:c,mapW:this.mapContainerEl.clientWidth,mapH:this.mapContainerEl.clientHeight,offsetY:E,pad:q})}let{dx:n,flipBelow:o}=this.clampOffset;this.container.style.left=`${l.x+n}px`,o?(this.container.style.top=`${l.y+E}px`,this.container.style.transform="translate(-50%, 0)"):(this.container.style.top=`${l.y-E}px`,this.container.style.transform="translate(-50%, -100%)")}onRemove(){this.attached=!1,this.container.remove()}updatePosition(t){(t.lat!==this.position.lat||t.lng!==this.position.lng)&&(this.clampOffset=null),this.position=t,this.attached&&this.draw()}}return b=e,b}function P(e){for(let r of e)typeof r.setMap=="function"?r.setMap(null):r.map=null}var Y="#b3261e",D=40,X=64,$=14;function j(e,r){let s=r.count,t=Math.min(X,D+Math.round(Math.log10(s+1)*$)),a=document.createElement("div");return a.textContent=String(s),a.style.display="flex",a.style.alignItems="center",a.style.justifyContent="center",a.style.width=`${t}px`,a.style.height=`${t}px`,a.style.borderRadius="50%",a.style.backgroundColor=Y,a.style.border="2px solid #ffffff",a.style.boxShadow="0 1px 4px rgba(0, 0, 0, 0.4)",a.style.color="#ffffff",a.style.fontFamily="inherit",a.style.fontWeight="700",a.style.fontSize=t>=52?"15px":"13px",new e.AdvancedMarkerElement({position:r.position,content:a})}var R=!1;async function K(e,r,s,t){let a;try{a=await import("@googlemaps/markerclusterer")}catch(n){R||(R=!0,console.warn('[react-listing-engine] "@googlemaps/markerclusterer" is not installed -- rendering plain (unclustered) markers instead. Install "@googlemaps/markerclusterer" to enable clustering.',n));return}if(e.layers.get(r)!==s)return;let l=new a.MarkerClusterer({map:e.map,markers:s,algorithmOptions:{maxZoom:t.maxZoom},renderer:{render:n=>j(e.markerLib,n)}});e.clusterers.set(r,l)}function O(e,r){let s=e.clusterers.get(r);s&&(s.setMap(null),e.clusterers.delete(r))}var T=!1;function N(){T||(T=!0,console.warn('[react-listing-engine] Marker clustering is not supported in `styles` (OverlayView) mode -- "@googlemaps/markerclusterer" only manages Marker/AdvancedMarkerElement instances. Rendering plain, unclustered overlay markers instead. Use a `mapId` (advanced-marker mode) to enable clustering.'))}function Q(e,r){return r.markers.map(s=>{let t=new e.markerLib.AdvancedMarkerElement({map:e.map,position:s.position,content:W(s,e.markerLib),gmpClickable:!!r.onMarkerClick});if(r.onMarkerClick){let a=r.onMarkerClick;t.addListener("click",()=>a(s.id))}return t})}function F(e,r,s,t){e.classList.toggle("rle-marker--selected",r===s),e.classList.toggle("rle-marker--hovered",r===t&&r!==s)}function J(e,r,s){let t=U(),a=new Map;for(let o of s??[])a.set(o.markerId,o);let l=new Set,n=r.markers.map(o=>{let i=r.onMarkerClick,c=i?()=>i(o.id):void 0,d=a.get(o.id);if(d&&!l.has(d)){l.add(d),d.onClick=c,te(d.getPosition(),o.position)||d.updatePosition(o.position);let p=I(o);return ne(d.getContent(),p)||d.setContent(p),d}let u=new t(o.id,o.position,I(o),c,ee(e,o.id));return u.setMap(e.map),u});for(let o of s??[])l.has(o)||o.setMap(null);return n}function ee(e,r){return{onContainerAdd:s=>{e.markerElements.set(r,s),F(s,r,e.selectedMarkerId,e.hoveredMarkerId)},onContainerRemove:s=>{e.markerElements.get(r)===s&&e.markerElements.delete(r)}}}function te(e,r){return e.lat===r.lat&&e.lng===r.lng}function ne(e,r){return e===r||e.outerHTML===r.outerHTML}function re(e,r){let s=e.layerMarkerIds.get(r);if(s){for(let t of s)e.markerElements.delete(t);e.layerMarkerIds.delete(r)}}function oe(e){let r=e.getSouthWest(),s=e.getNorthEast();return{west:r.lng(),south:r.lat(),east:s.lng(),north:s.lat()}}var C=256,ie=1.2,ae=320,se=450,le=2600,A="rle-map-flying";function H(e,r){let s=Math.min(Math.max(Math.sin(e*Math.PI/180),-.9999),.9999);return{x:C*(.5+r/360),y:C*(.5-Math.log((1+s)/(1-s))/(4*Math.PI))}}function S(e){let r=Math.PI-2*Math.PI*e.y/C;return{lat:180/Math.PI*Math.atan(.5*(Math.exp(r)-Math.exp(-r))),lng:(e.x/C-.5)*360}}function ce(e,r,s){let t=H(e.north,e.east),a=H(e.south,e.west),l=Math.abs(t.x-a.x),n=Math.abs(t.y-a.y);return l===0||n===0||r===0||s===0?null:{center:S({x:(t.x+a.x)/2,y:(t.y+a.y)/2}),zoom:Math.min(Math.log2(r/l),Math.log2(s/n))}}function de(e,r,s){let t=s/2**e.zoom,a=s/2**r.zoom,l=r.x-e.x,n=r.y-e.y,o=l*l+n*n,i=ie,c=i*i;if(o<1e-12){let M=Math.abs(Math.log(a/t))/i,g=a<t?-1:1;return{S:M,at:h=>({x:e.x,y:e.y,zoom:Math.log2(s/(t*Math.exp(g*i*(h*M))))})}}let d=Math.sqrt(o),u=(a*a-t*t+c*c*o)/(2*t*c*d),p=(a*a-t*t-c*c*o)/(2*a*c*d),m=Math.log(Math.sqrt(u*u+1)-u),v=(Math.log(Math.sqrt(p*p+1)-p)-m)/i,y=Math.cosh(m);return{S:v,at:M=>{let g=i*(M*v)+m,h=t/(c*d)*(y*Math.tanh(g)-Math.sinh(m)),_=t*y/Math.cosh(g);return{x:e.x+h*l,y:e.y+h*n,zoom:Math.log2(s/_)}}}}function ue(e){return e*(2-e)}function pe(e,r,s){let t=performance.now(),a,l=c=>{let d=S(c);typeof e.map.moveCamera=="function"?e.map.moveCamera({center:d,zoom:c.zoom}):(e.map.setZoom(c.zoom),e.map.setCenter(d))},n=()=>{e.containerEl.classList.remove(A),e.containerEl.removeEventListener("pointerdown",o,!0),e.containerEl.removeEventListener("wheel",o,!0)},o=()=>{cancelAnimationFrame(a),n(),e.cancelFlight===o&&(e.cancelFlight=null)},i=()=>{let c=Math.min(1,(performance.now()-t)/s);l(r.at(ue(c))),c<1?a=requestAnimationFrame(i):(n(),e.cancelFlight=null)};return e.containerEl.classList.add(A),e.containerEl.addEventListener("pointerdown",o,!0),e.containerEl.addEventListener("wheel",o,!0),a=requestAnimationFrame(i),o}function me(e,r,s){if(typeof ResizeObserver>"u")return;let t=!1,a=()=>{let{width:n,height:o}=e.getBoundingClientRect();n===0||o===0||(google.maps.event.trigger(r,"resize"),t||(t=!0,r.setCenter(s)))},l=new ResizeObserver(a);return l.observe(e),typeof requestAnimationFrame<"u"?requestAnimationFrame(a):queueMicrotask(a),l}function fe(e){if(!e.apiKey)throw new Error("googleProvider: config.apiKey is required (no hardcoded fallback key is ever used).");let r=!1,s=()=>{r||(z({...e.loaderOptions,key:e.apiKey}),r=!0)},t,a=0;return{async mount(l,n){let o=++a;s();let i=await x("maps"),c=await x("marker"),d=n.center??{lat:0,lng:0},u=e.styles!=null||e.overlayMarkers===!0,p=new i.Map(l,{...e.mapOptions,center:d,zoom:n.zoom??10,...u?e.styles!=null?{styles:e.styles}:e.mapId!=null?{mapId:e.mapId}:{}:{mapId:e.mapId??G}}),m=me(l,p,d),f={map:p,containerEl:l,fullscreenEl:n.fullscreenTarget??l,markerLib:c,markerMode:u?"overlay":"advanced",layers:new Map,clusterers:new Map,boundsListeners:new Set,clickListeners:new Set,resizeObserver:m,markerElements:new Map,layerMarkerIds:new Map,selectedMarkerId:null,hoveredMarkerId:null,cancelFlight:null};return o===a&&(t=f),{raw:f,nativeMap:f.map}},renderLayer(l,n){let o=L(l),i=o.layers.get(n.id),c;o.markerMode==="overlay"?(c=J(o,n,i),o.layers.set(n.id,c),o.layerMarkerIds.set(n.id,n.markers.map(u=>u.id)),n.clustering&&N()):(i&&(P(i),o.layers.delete(n.id)),O(o,n.id),c=Q(o,n),o.layers.set(n.id,c),n.clustering&&K(o,n.id,c,n.clustering));let d=!1;return()=>{d||(d=!0,o.layers.get(n.id)===c&&(P(c),o.layers.delete(n.id),O(o,n.id),re(o,n.id)))}},onBoundsChange(l,n){let o=L(l),i=o.map.addListener("idle",()=>{let d=o.map.getBounds();d&&n(oe(d))});o.boundsListeners.add(i);let c=!1;return()=>{c||(c=!0,i.remove(),o.boundsListeners.delete(i))}},onMapClick(l){let n=t;if(!n)return()=>{};let o=n.map.addListener("click",()=>l());n.clickListeners.add(o);let i=!1;return()=>{i||(i=!0,o.remove(),n.clickListeners.delete(o))}},fitBounds(l,n,o){let i=L(l);if(i.cancelFlight?.(),i.cancelFlight=null,!o?.animate){i.map.fitBounds(n);return}let c=i.map.getZoom(),d=i.map.getCenter(),u=ce(n,i.containerEl.clientWidth,i.containerEl.clientHeight);if(c==null||!d||!u){i.map.fitBounds(n);return}let p=typeof i.map.getRenderingType=="function"?i.map.getRenderingType():void 0,m=typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;if(p!=="VECTOR"||m){i.map.fitBounds(n);return}i.map.setOptions({isFractionalZoomEnabled:!0});let f={...H(d.lat(),d.lng()),zoom:c},v={...H(u.center.lat,u.center.lng),zoom:u.zoom},y=Math.max(i.containerEl.clientWidth,i.containerEl.clientHeight),M=de(f,v,y),g=Math.min(le,Math.max(se,M.S*ae));i.cancelFlight=pe(i,M,g)},destroy(l){let n=L(l);n.resizeObserver?.disconnect(),n.cancelFlight?.(),n.cancelFlight=null;for(let o of n.boundsListeners)o.remove();n.boundsListeners.clear();for(let o of n.clickListeners)o.remove();n.clickListeners.clear();for(let o of[...n.clusterers.keys()])O(n,o);for(let o of n.layers.values())P(o);n.layers.clear(),n.markerElements.clear(),n.layerMarkerIds.clear(),t===n&&(t=void 0)},updateMarkerStates(l,n){if(t){t.selectedMarkerId=l,t.hoveredMarkerId=n;for(let[o,i]of t.markerElements)F(i,o,l,n)}},mountOverlay(l){let n=document.createElement("div");if(n.style.position="absolute",n.style.transform="translate(-50%, -100%)",n.style.pointerEvents="auto",!t)return{container:n,setPosition:()=>{},unmount:()=>n.remove()};let o=Z(),i=new o(n,l,t.containerEl);return i.setMap(t.map),{container:n,setPosition:c=>i.updatePosition(c),unmount:()=>{i.setMap(null),n.remove()}}},zoomIn(){t&&t.map.setZoom((t.map.getZoom()??0)+1)},zoomOut(){t&&t.map.setZoom((t.map.getZoom()??0)-1)},toggleFullscreen(){if(!t)return;let l=t.fullscreenEl,n=document.fullscreenElement;n!=null&&l.contains(n)?typeof document.exitFullscreen=="function"&&document.exitFullscreen()?.catch(()=>{}):typeof l.requestFullscreen=="function"&&l.requestFullscreen()?.catch(()=>{})}}}export{fe as googleProvider};
|
package/dist/styled/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
2
|
-
var
|
|
2
|
+
var _chunkXVPGWJW3cjs = require('../chunk-XVPGWJW3.cjs');var _jsxruntime = require('react/jsx-runtime');function L({children:o}){return _jsxruntime.jsx.call(void 0, _chunkXVPGWJW3cjs.r,{..._chunkXVPGWJW3cjs.Q,children:o})}exports.BottomNav = _chunkXVPGWJW3cjs.F; exports.BottomSheet = _chunkXVPGWJW3cjs.R; exports.ListingApp = _chunkXVPGWJW3cjs.T; exports.StyledCard = _chunkXVPGWJW3cjs.G; exports.StyledComponentsProviderWithDefaults = L; exports.StyledEmpty = _chunkXVPGWJW3cjs.H; exports.StyledFilterPanel = _chunkXVPGWJW3cjs.I; exports.StyledListingLayout = _chunkXVPGWJW3cjs.S; exports.StyledLoading = _chunkXVPGWJW3cjs.J; exports.StyledMarker = _chunkXVPGWJW3cjs.K; exports.StyledPopup = _chunkXVPGWJW3cjs.L; exports.StyledResultHeader = _chunkXVPGWJW3cjs.M; exports.StyledSearch = _chunkXVPGWJW3cjs.N; exports.StyledSidebar = _chunkXVPGWJW3cjs.O; exports.StyledToolbar = _chunkXVPGWJW3cjs.P; exports.styledDefaultComponents = _chunkXVPGWJW3cjs.Q;
|
package/dist/styled/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{F as r,G as p,H as i,I as y,J as d,K as l,L as n,M as m,N as s,O as a,P as S,Q as t,R as f,S as P,T as u,r as e}from"../chunk-
|
|
2
|
+
import{F as r,G as p,H as i,I as y,J as d,K as l,L as n,M as m,N as s,O as a,P as S,Q as t,R as f,S as P,T as u,r as e}from"../chunk-2N3ICJ5L.js";import{jsx as g}from"react/jsx-runtime";function L({children:o}){return g(e,{...t,children:o})}export{r as BottomNav,f as BottomSheet,u as ListingApp,p as StyledCard,L as StyledComponentsProviderWithDefaults,i as StyledEmpty,y as StyledFilterPanel,P as StyledListingLayout,d as StyledLoading,l as StyledMarker,n as StyledPopup,m as StyledResultHeader,s as StyledSearch,a as StyledSidebar,S as StyledToolbar,t as styledDefaultComponents};
|
package/dist/testing/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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;"use client";
|
|
2
|
-
var o= (_class =class{constructor() { _class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);_class.prototype.__init6.call(this);_class.prototype.__init7.call(this);_class.prototype.__init8.call(this);_class.prototype.__init9.call(this);_class.prototype.__init10.call(this);_class.prototype.__init11.call(this);_class.prototype.__init12.call(this); }__init() {this.mounts=[]}__init2() {this.renderedLayers=[]}__init3() {this.removedLayers=[]}__init4() {this.fitBoundsCalls=[]}__init5() {this.destroyed=[]}__init6() {this.destroyCount=0}__init7() {this.markerStates=null}__init8() {this.overlays=[]}__init9() {this.zoomCalls=[]}__init10() {this.fullscreenToggles=0}__init11() {this.boundsListeners=new Set}__init12() {this.mapClickListeners=new Set}mount(t,e){let n={raw:{el:t,opts:e},nativeMap:{el:t,opts:e}};return this.mounts.push(n),this.fullscreenTarget=_nullishCoalesce(e.fullscreenTarget, () => (t)),n}renderLayer(t,e){this.renderedLayers.
|
|
2
|
+
var o= (_class =class{constructor() { _class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);_class.prototype.__init6.call(this);_class.prototype.__init7.call(this);_class.prototype.__init8.call(this);_class.prototype.__init9.call(this);_class.prototype.__init10.call(this);_class.prototype.__init11.call(this);_class.prototype.__init12.call(this); }__init() {this.mounts=[]}__init2() {this.renderedLayers=[]}__init3() {this.removedLayers=[]}__init4() {this.fitBoundsCalls=[]}__init5() {this.destroyed=[]}__init6() {this.destroyCount=0}__init7() {this.markerStates=null}__init8() {this.overlays=[]}__init9() {this.zoomCalls=[]}__init10() {this.fullscreenToggles=0}__init11() {this.boundsListeners=new Set}__init12() {this.mapClickListeners=new Set}mount(t,e){let n={raw:{el:t,opts:e},nativeMap:{el:t,opts:e}};return this.mounts.push(n),this.fullscreenTarget=_nullishCoalesce(e.fullscreenTarget, () => (t)),n}renderLayer(t,e){let n=this.renderedLayers.findIndex(s=>s.id===e.id);return n===-1?this.renderedLayers.push(e):this.renderedLayers[n]=e,()=>{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,n){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"&&_optionalChain([this, 'access', _ => _.fullscreenTarget, 'access', _2 => _2.requestFullscreen, 'call', _3 => _3(), 'optionalAccess', _4 => _4.catch, 'call', _5 => _5(()=>{})])}}, _class);var d=class{constructor(t,e,n,s=r=>r.id){this.rows=t;this.predicate=e;this.toLatLng=n;this.idOf=s}async list(t,e){let n=this.rows.filter(u=>this.predicate(u,t)),s=e.cursor!=null?Number(e.cursor)+1:_nullishCoalesce(e.offset, () => (0)),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}};exports.FakeMapProvider = o; exports.InMemoryEntityAdapter = d;
|
package/dist/testing/index.d.cts
CHANGED
|
@@ -44,6 +44,14 @@ declare class FakeMapProvider implements MapProvider {
|
|
|
44
44
|
private readonly boundsListeners;
|
|
45
45
|
private readonly mapClickListeners;
|
|
46
46
|
mount(el: HTMLElement, opts: MapInitOptions): MapHandle;
|
|
47
|
+
/**
|
|
48
|
+
* Mirrors the real providers' contract for a layer id rendered again: the new
|
|
49
|
+
* render REPLACES the previous entry in place (same position in
|
|
50
|
+
* `renderedLayers`), and the superseded render's unsubscribe becomes a no-op
|
|
51
|
+
* -- the layer is reconciled, not torn down and rebuilt, so a points reload
|
|
52
|
+
* leaves `removedLayers` alone. Only unsubscribing the CURRENT render removes
|
|
53
|
+
* the entry and records it in `removedLayers`.
|
|
54
|
+
*/
|
|
47
55
|
renderLayer(_handle: MapHandle, layer: RenderedLayer): Unsubscribe;
|
|
48
56
|
onBoundsChange(_handle: MapHandle, cb: BoundsListener): Unsubscribe;
|
|
49
57
|
/** Test-only: simulates a user pan/zoom by invoking every registered bounds listener. */
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -44,6 +44,14 @@ declare class FakeMapProvider implements MapProvider {
|
|
|
44
44
|
private readonly boundsListeners;
|
|
45
45
|
private readonly mapClickListeners;
|
|
46
46
|
mount(el: HTMLElement, opts: MapInitOptions): MapHandle;
|
|
47
|
+
/**
|
|
48
|
+
* Mirrors the real providers' contract for a layer id rendered again: the new
|
|
49
|
+
* render REPLACES the previous entry in place (same position in
|
|
50
|
+
* `renderedLayers`), and the superseded render's unsubscribe becomes a no-op
|
|
51
|
+
* -- the layer is reconciled, not torn down and rebuilt, so a points reload
|
|
52
|
+
* leaves `removedLayers` alone. Only unsubscribing the CURRENT render removes
|
|
53
|
+
* the entry and records it in `removedLayers`.
|
|
54
|
+
*/
|
|
47
55
|
renderLayer(_handle: MapHandle, layer: RenderedLayer): Unsubscribe;
|
|
48
56
|
onBoundsChange(_handle: MapHandle, cb: BoundsListener): Unsubscribe;
|
|
49
57
|
/** Test-only: simulates a user pan/zoom by invoking every registered bounds listener. */
|
package/dist/testing/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
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},nativeMap:{el:t,opts:e}};return this.mounts.push(n),this.fullscreenTarget=e.fullscreenTarget??t,n}renderLayer(t,e){this.renderedLayers.
|
|
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},nativeMap:{el:t,opts:e}};return this.mounts.push(n),this.fullscreenTarget=e.fullscreenTarget??t,n}renderLayer(t,e){let n=this.renderedLayers.findIndex(s=>s.id===e.id);return n===-1?this.renderedLayers.push(e):this.renderedLayers[n]=e,()=>{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,n){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 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?Number(e.cursor)+1:e.offset??0,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};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-listing-engine",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.7",
|
|
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": [
|
|
@@ -80,14 +80,6 @@
|
|
|
80
80
|
"optional": true
|
|
81
81
|
}
|
|
82
82
|
},
|
|
83
|
-
"scripts": {
|
|
84
|
-
"build": "tsup",
|
|
85
|
-
"test": "vitest run",
|
|
86
|
-
"test:watch": "vitest",
|
|
87
|
-
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
88
|
-
"lint": "eslint .",
|
|
89
|
-
"release": "changeset publish"
|
|
90
|
-
},
|
|
91
83
|
"devDependencies": {
|
|
92
84
|
"@changesets/cli": "^2.31.1",
|
|
93
85
|
"@googlemaps/js-api-loader": "^2.1.1",
|
|
@@ -111,5 +103,13 @@
|
|
|
111
103
|
},
|
|
112
104
|
"publishConfig": {
|
|
113
105
|
"access": "public"
|
|
106
|
+
},
|
|
107
|
+
"scripts": {
|
|
108
|
+
"build": "tsup",
|
|
109
|
+
"test": "vitest run",
|
|
110
|
+
"test:watch": "vitest",
|
|
111
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
112
|
+
"lint": "eslint .",
|
|
113
|
+
"release": "changeset publish"
|
|
114
114
|
}
|
|
115
|
-
}
|
|
115
|
+
}
|
package/dist/chunk-NW4P53OH.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
var ee=class{state;listeners=new Set;constructor(e){this.state=this.freezeState({filters:{...e.filters},results:e.results?{items:[...e.results.items],nextCursor:e.results.nextCursor,total:e.results.total}:{items:[],nextCursor:null},bounds:null,selection:null,hovered:null,pagination:{mode:e.mode??"paged",loading:!1,loaded:e.results!=null,pageIndex:0},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},pagination:{...this.state.pagination,loaded:!0}})}appendResults(e){this.setState({results:{items:[...this.state.results.items,...e.items],nextCursor:e.nextCursor,total:e.total},pagination:{...this.state.pagination,loaded:!0}})}setBounds(e){this.setState({bounds:e?{...e}:null})}setSelection(e){this.setState({selection:e})}setHovered(e){this.setState({hovered:e})}setLayerVisible(e,i){this.setState({layers:{...this.state.layers,[e]:i}})}setLoading(e){this.setState({pagination:{...this.state.pagination,loading:e}})}setPageIndex(e){this.setState({pagination:{...this.state.pagination,pageIndex: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 $=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(),n=e.filter(s=>this.defs.has(s));n.forEach((s,o)=>{this.defs.get(s).order=o});let r=new Set(n);return i.filter(s=>!r.has(s.key)).forEach((s,o)=>{s.order=n.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(n=>Object.hasOwn(e,n.key)).map(n=>n.toParams(e[n.key])).reduce((n,r)=>({...n,...r}),{})}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 te=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 ie=class{map=new Map;dispose(){this.map.clear()}emit(e){let i=this.map.get(e.type);if(i)for(let r of[...i])r(e);let n=this.map.get("*");if(n)for(let r of[...n])r(e)}on(e,i){let n=this.map.get(e);return n||(n=new Set,this.map.set(e,n)),n.add(i),()=>{n.delete(i)}}};var ze={pagination:"paged",pageSize:20,debounceMs:250};var ne=class{options;constructor(e){this.options=Object.freeze({...ze,...e})}};var re=class{filters;map;datasets;primaryDatasetId;store;disposed=!1;emitter=new ie;config;debounceTimer=null;debounceResolve=null;queryToken=0;pointsToken=0;mapHandle=null;pendingFit=null;constructor(e){this.datasets=e.datasets,this.filters=e.filters??new $,this.map=e.map,this.config=new ne(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 ee({filters:e.initialFilters??{},mode:this.config.options.pagination,results:e.initialResults})}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,n=this.config.options.debounceMs;return n<=0?this.runQuery(i):new Promise(r=>{this.debounceResolve=r,this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.debounceResolve=null,r(this.runQuery(i))},n)})}async loadPage(){let e=this.state.results.nextCursor;if(e===null)return;let i=++this.queryToken,n=this.primaryDataset();this.store.setLoading(!0);try{let r=await n.adapter.list(this.currentFilters(),{cursor:e,limit:this.config.options.pageSize});if(i!==this.queryToken)return;this.config.options.pagination==="infinite"?this.store.appendResults(r):this.store.setResults(r),this.emitter.emit({type:"ResultsLoaded",datasetId:this.primaryDatasetId,count:r.items.length})}finally{i===this.queryToken&&this.store.setLoading(!1)}}async goToPage(e){if(e<0)return;let i=++this.queryToken,n=this.primaryDataset();this.store.setLoading(!0);try{let r=await n.adapter.list(this.currentFilters(),{offset:e*this.config.options.pageSize,limit:this.config.options.pageSize});if(i!==this.queryToken)return;this.store.setResults(r),this.store.setPageIndex(e),this.emitter.emit({type:"ResultsLoaded",datasetId:this.primaryDatasetId,count:r.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(),n=++this.pointsToken;await Promise.allSettled(this.datasets.visibleIds().map(async r=>{let s=this.datasets.get(r);if(!s)return;let o=await s.adapter.getPoints(i,e);n===this.pointsToken&&this.store.setPoints(r,o)}))}setMapHandle(e){if(this.mapHandle=e,!e||!this.pendingFit||!this.map)return;let{bounds:i,options:n}=this.pendingFit;this.pendingFit=null,this.map.fitBounds(e,i,n)}fitBounds(e,i){if(this.map){if(!this.mapHandle){this.pendingFit={bounds:e,options:i};return}this.map.fitBounds(this.mapHandle,e,i)}}selectPoint(e,i){this.store.setSelection(i);let n=this.state.points[e]?.find(r=>r.id===i);n&&this.emitter.emit({type:"PointClicked",datasetId:e,id:n.id,entity:n.entity})}setHovered(e,i){this.store.setHovered(i)}toggleLayer(e){let n=!(this.state.layers[e]??!0);this.store.setLayerVisible(e,n),this.emitter.emit({type:"LayerToggled",datasetId:e,visible:n})}subscribe(e){return this.store.subscribe(e)}on(e,i){return this.emitter.on(e,i)}get isDisposed(){return this.disposed}attachMap(e){this.disposed||this.map===e||this.map||(this.map=e,this.store.setFilters({}))}dispose(){this.clearDebounce(),this.emitter.dispose(),this.mapHandle=null,this.disposed=!0}async runQuery(e){if(e!==this.queryToken)return;let i=this.primaryDataset();this.store.setLoading(!0);try{let n=await i.adapter.list(this.currentFilters(),{cursor:null,limit:this.config.options.pageSize});if(e!==this.queryToken)return;this.store.setResults(n),this.store.setPageIndex(0),this.emitter.emit({type:"ResultsLoaded",datasetId:this.primaryDatasetId,count:n.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 Ke(...t){let e={config:{},filters:new $,datasets:new te};for(let i of t)i(e);return e}var Ue=t=>e=>{e.config={...e.config,...t}},Ve=t=>e=>{e.map=t},qe=t=>e=>{e.datasets.add(t)},$e=t=>e=>{t(e.filters)},Ki=t=>e=>{e.urlSync=t},We=t=>e=>{e.initialFilters=t},je=t=>e=>{e.initialResults=t},Ui=t=>e=>{e.primaryDatasetId=t};import{createContext as kt,useContext as St}from"react";import{jsx as k,jsxs as Ze}from"react/jsx-runtime";function Ct(t){return String(t?.title??"")}var It=({item:t})=>k("div",{children:Ct(t)}),Et=()=>k("div",{}),fe=()=>k("div",{}),xt=({children:t})=>k("div",{children:t}),Rt=({children:t})=>k("div",{children:t}),Nt=({value:t,onChange:e,placeholder:i})=>k("input",{type:"search",value:t,placeholder:i,onChange:n=>e(n.target.value),"aria-label":i??"Search"}),Mt=()=>k("div",{role:"status",children:"No results"}),Dt=()=>k("div",{role:"status","aria-busy":"true",children:"Loading\u2026"}),Bt=({count:t})=>Ze("div",{children:[t," results"]}),Ot=({children:t})=>k("div",{children:t}),_t=({view:t,onViewChange:e})=>Ze("nav",{"aria-label":"Listing navigation",children:[k("button",{type:"button","aria-pressed":t==="list",onClick:()=>e("list"),children:"List"}),k("button",{type:"button","aria-pressed":t==="map",onClick:()=>e("map"),children:"Map"})]}),w={BottomNav:_t,Card:It,Marker:Et,Popup:fe,Sidebar:xt,FilterPanel:Rt,Search:Nt,Empty:Mt,Loading:Dt,ResultHeader:Bt,Toolbar:Ot},Ge=kt(w);function Qe(t){let{BottomNav:e,Card:i,Marker:n,Popup:r,Sidebar:s,FilterPanel:o,Search:a,Empty:p,Loading:l,ResultHeader:d,Toolbar:m,children:b}=t,E={BottomNav:e??w.BottomNav,Card:i??w.Card,Marker:n??w.Marker,Popup:r??w.Popup,Sidebar:s??w.Sidebar,FilterPanel:o??w.FilterPanel,Search:a??w.Search,Empty:p??w.Empty,Loading:l??w.Loading,ResultHeader:d??w.ResultHeader,Toolbar:m??w.Toolbar};return k(Ge.Provider,{value:E,children:b})}function S(){return St(Ge)}import{createContext as At}from"react";var se=At(null);import{useContext as Ht}from"react";function L(){let t=Ht(se);if(t===null)throw new Error("useListing must be used within a <ListingProvider>");return t}import{useCallback as Xe,useSyncExternalStore as zt}from"react";function C(){let t=L(),e=Xe(n=>t.subscribe(n),[t]),i=Xe(()=>t.state,[t]);return zt(e,i,i)}import{useCallback as Je}from"react";function oe(){let t=L(),e=C(),i=Je(r=>t.applyFilters(r),[t]),n=Je((r,s)=>t.applyFilters({[r]:s}),[t]);return{filters:e.filters,set:i,setField:n}}import{jsx as Z,jsxs as Kt}from"react/jsx-runtime";function ye({className:t,groupClassName:e,hideLabels:i,draft:n,onDraftChange:r}={}){let s=L(),{FilterPanel:o}=S(),{filters:a}=oe(),p=n!==void 0&&r!==void 0,l=p?n:a;return Z(o,{children:Z("div",{className:t??"space-y-5",children:s.filters.list().map(d=>{if(typeof d.render=="string")return Z("div",{"data-filter":d.key,className:e},d.key);let m=d.render;return Kt("div",{className:e,children:[d.label&&!i&&Z("div",{className:"mb-1.5 text-[13px] font-medium text-foreground",children:d.label}),Z(m,{value:d.fromParams(l),onChange:b=>p?r(d.toParams(b)):void s.applyFilters(d.toParams(b))})]},d.key)})})})}function W(){return C().results}import{jsx as ae}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 Ye({className:t}={}){let e=L(),{items:i}=W(),{pagination:n,selection:r}=C(),{Card:s,Empty:o,Loading:a}=S();return i.length===0&&(n.loading||!n.loaded)?ae(a,{}):i.length===0?ae(o,{}):ae("div",{role:"list",className:t,children:i.map((p,l)=>{let d=Ut(p,l);return ae(s,{item:p,selected:r===d,onSelect:()=>e.selectPoint(e.primaryDatasetId,d)},d)})})}import{useEffect as X,useRef as O,useState as et}from"react";import{createPortal as Vt}from"react-dom";import{jsx as he,jsxs as nt}from"react/jsx-runtime";var qt={west:-179.9,south:-85,east:179.9,north:85},tt=.1,it=.02;function $t(t){if(t.length===0)return null;let e=t[0].lng,i=t[0].lng,n=t[0].lat,r=t[0].lat;for(let{lat:a,lng:p}of t)p<e&&(e=p),p>i&&(i=p),a<n&&(n=a),a>r&&(r=a);let s=r>n?(r-n)*tt:it,o=i>e?(i-e)*tt:it;return{west:e-o,east:i+o,south:n-s,north:r+s}}function rt(t){let{center:e,zoom:i,fallback:n,mapControls:r,onMapReady:s}=t,o=L(),a=C(),p=O(s);p.current=s;let l=O(null),d=O(null),m=O(null),[b,E]=et(!1),_=O(!1),F=O(!1),B=O(!1),u=o.map;X(()=>{let v=m.current;if(!u||!v)return;let f=[];for(let y of Object.keys(a.points)){if(a.layers[y]===!1)continue;let h=o.datasets.get(y),R=a.points[y]??[],z={id:y,markers:R.map(T=>({id:T.id,position:T.position,iconUrl:h?.marker.iconUrl?.(T.entity),element:h?.marker.element?.(T.entity)})),clustering:h?.clustering,onMarkerClick:T=>o.selectPoint(y,T)};f.push(u.renderLayer(v,z))}return()=>{f.forEach(y=>y())}},[o,u,b,a.points,a.layers]),X(()=>{if(!l.current||!u)return;let v=l.current,f=!1,y=null;return(async()=>{let h=await u.mount(v,{center:e,zoom:i,fullscreenTarget:d.current??void 0});if(f){u.destroy(h);return}m.current=h,o.setMapHandle(h),y=u.onBoundsChange(h,R=>{B.current?B.current=!1:F.current=!0,o.loadPoints(R)}),E(!0),p.current?.(h.nativeMap??h.raw),o.loadPoints(qt)})(),()=>{f=!0,y?.(),m.current&&(u.destroy(m.current),m.current=null,o.setMapHandle(null),p.current?.(null)),E(!1)}},[o,u]),X(()=>{let v=m.current;if(!u||!v||e||_.current||F.current)return;let f=[];for(let h of Object.keys(a.points))if(a.layers[h]!==!1)for(let R of a.points[h]??[])f.push(R.position);let y=$t(f);y&&(_.current=!0,B.current=!0,u.fitBounds(v,y))},[u,e,b,a.points,a.layers]),X(()=>{u?.updateMarkerStates(a.selection,a.hovered)},[u,b,a.selection,a.hovered]);let{Popup:A}=S(),x=A!==fe,V=a.points[o.primaryDatasetId]??[],g=a.selection!=null?V.find(v=>v.id===a.selection):void 0,[N,H]=et(null),q=O(g);return q.current=g,X(()=>{let v=m.current;if(!u||!v||!x)return;let f=q.current;if(!f)return;let y=u.mountOverlay(f.position);H({entity:f.entity,position:f.position,container:y.container});let h=()=>o.selectPoint(o.primaryDatasetId,null),R=T=>{T.key==="Escape"&&h()};document.addEventListener("keydown",R);let z=u.onMapClick(h);return()=>{document.removeEventListener("keydown",R),z(),y.unmount(),H(null)}},[o,u,b,a.selection,x]),nt("div",{ref:d,className:"relative h-full min-h-0 w-full",children:[nt("div",{ref:l,className:!u&&n?"flex h-full min-h-0 w-full items-center justify-center":"h-full min-h-0 w-full",children:[!u&&n,x&&N?Vt(he(A,{entity:N.entity,onClose:()=>o.selectPoint(o.primaryDatasetId,null)}),N.container):null]}),r!=null&&he("div",{className:"pointer-events-none absolute inset-0",children:he("div",{className:"pointer-events-auto",children:r})})]})}import{jsx as J,jsxs as jt}from"react/jsx-runtime";var ve="gap";function Wt(t,e){if(t<=7)return Array.from({length:t},(s,o)=>o+1);let i=Math.max(2,e-1),n=Math.min(t-1,e+1),r=[1];i>2&&r.push(ve);for(let s=i;s<=n;s+=1)r.push(s);return n<t-1&&r.push(ve),r.push(t),r}function st(){let t=L(),{results:e,pagination:i}=C();if(i.mode==="infinite")return e.nextCursor==null?null:J("button",{type:"button",disabled:i.loading,onClick:()=>{t.loadPage()},children:"Load more"});let n=t.options.pageSize,{pageIndex:r}=i,s=r+1,o=e.total!=null?Math.ceil(e.total/n):null,a=o!=null?s<o:e.nextCursor!=null||e.items.length>=n;if(o!=null?o<=1:r===0&&!a)return null;let p=l=>()=>{t.goToPage(l)};return jt("nav",{className:"rle-pagination","aria-label":"Pagination",children:[J("button",{type:"button",className:"rle-page-btn rle-page-btn--nav","aria-label":"Previous page",disabled:i.loading||r===0,onClick:p(r-1),children:"\u2039"}),o!=null&&Wt(o,s).map((l,d)=>l===ve?J("span",{className:"rle-page-ellipsis",children:"\u2026"},`gap-${d}`):J("button",{type:"button",className:l===s?"rle-page-btn rle-page-btn--active":"rle-page-btn","aria-label":`Page ${l}`,"aria-current":l===s?"page":void 0,disabled:i.loading,onClick:p(l-1),children:l},l)),J("button",{type:"button",className:"rle-page-btn rle-page-btn--nav","aria-label":"Next page",disabled:i.loading||!a,onClick:p(r+1),children:"\u203A"})]})}import{jsx as Gt}from"react/jsx-runtime";function ot(){let{items:t,total:e}=W(),{ResultHeader:i}=S();return Gt(i,{count:t.length,total:e})}import{useEffect as Qt,useRef as Zt}from"react";function at(t,e){let i=L(),n=Zt(e);n.current=e,Qt(()=>i.on(t,r=>n.current(r)),[i,t])}import{useCallback as Xt,useEffect as lt,useRef as Jt,useState as dt}from"react";import{jsx as Yt}from"react/jsx-runtime";function pt(t){let{children:e,...i}=t,[n]=dt(()=>i),r=Xt(()=>new re({datasets:n.datasets,filters:n.filters,config:n.config,map:n.map,initialFilters:n.initialFilters,initialResults:n.initialResults,primaryDatasetId:n.primaryDatasetId}),[n]),[s,o]=dt(r),a=Jt(s);a.current=s;let p=i.map;return lt(()=>{p&&s.attachMap(p)},[s,p]),lt(()=>{let l=a.current;return l.isDisposed&&(l=r(),a.current=l,o(l)),n.urlSync&&n.urlSync.start(l),()=>{n.urlSync&&n.urlSync.stop(),l.dispose()}},[n,r]),Yt(se.Provider,{value:s,children:e})}import{jsx as I,jsxs as Y}from"react/jsx-runtime";function ut({view:t,onViewChange:e}){return I("nav",{className:"rle-bottom-nav","aria-label":"Listing navigation",children:Y("div",{className:"rle-viewtoggle",role:"group","aria-label":"View",children:[Y("button",{type:"button",className:`rle-viewtoggle__btn${t==="list"?" rle-viewtoggle__btn--active":""}`,"aria-pressed":t==="list",onClick:()=>e("list"),children:[I(ei,{}),"List"]}),Y("button",{type:"button",className:`rle-viewtoggle__btn${t==="map"?" rle-viewtoggle__btn--active":""}`,"aria-pressed":t==="map",onClick:()=>e("map"),children:[I(ti,{}),"Map"]})]})})}function ei(){return Y("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:[I("line",{x1:"8",y1:"6",x2:"20",y2:"6"}),I("line",{x1:"8",y1:"12",x2:"20",y2:"12"}),I("line",{x1:"8",y1:"18",x2:"20",y2:"18"}),I("line",{x1:"4",y1:"6",x2:"4.01",y2:"6"}),I("line",{x1:"4",y1:"12",x2:"4.01",y2:"12"}),I("line",{x1:"4",y1:"18",x2:"4.01",y2:"18"})]})}function ti(){return Y("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:[I("polygon",{points:"1 6 8 3 16 6 23 3 23 18 16 21 8 18 1 21 1 6"}),I("line",{x1:"8",y1:"3",x2:"8",y2:"18"}),I("line",{x1:"16",y1:"6",x2:"16",y2:"21"})]})}function j(t){return typeof t!="number"?t:new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t)}import{Fragment as ni,jsx as M,jsxs as ct}from"react/jsx-runtime";function ii(t){return t?"rle-card rle-card--selected":"rle-card"}function be({item:t,selected:e,onSelect:i}){let n=t??{},r=ii(e),s=ct(ni,{children:[n.imageUrl?M("img",{src:n.imageUrl,alt:n.title??"",className:"rle-card-media"}):M("div",{className:"rle-card-media rle-card-media--placeholder","aria-hidden":"true"}),ct("div",{className:"rle-card-body",children:[n.title&&M("span",{className:"rle-card-title",children:n.title}),n.subtitle&&M("span",{className:"rle-card-address",children:n.subtitle}),n.badge&&M("div",{className:"rle-card-info",children:M("span",{className:"rle-card-info-item",children:n.badge})}),n.price!=null&&M("span",{className:"rle-card-price",children:j(n.price)})]})]});return i?M("button",{type:"button",onClick:i,"aria-pressed":e??!1,className:r,children:s}):M("article",{className:r,children:s})}import{jsx as le,jsxs as mt}from"react/jsx-runtime";function Le(t){return mt("div",{role:"status",className:"rle-empty",children:[mt("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:[le("circle",{cx:"11",cy:"11",r:"7"}),le("path",{d:"m21 21-4.3-4.3"})]}),le("p",{className:"rle-empty-title",children:"No results"}),le("p",{className:"rle-empty-hint",children:"Try adjusting your filters or search terms."})]})}import{jsx as ri}from"react/jsx-runtime";function Pe({children:t}){return ri("div",{className:"rle-filter-panel",children:t})}import{jsx as de,jsxs as si}from"react/jsx-runtime";function Te(t){return de("div",{className:"rle-loading",role:"status","aria-busy":"true","aria-label":"Loading results",children:Array.from({length:3}).map((e,i)=>si("div",{className:"rle-loading-item",children:[de("div",{className:"rle-skeleton",style:{aspectRatio:"4 / 3",width:"100%"}}),de("div",{className:"rle-skeleton",style:{height:16,width:"65%"}}),de("div",{className:"rle-skeleton",style:{height:12,width:"35%"}})]},i))})}import{jsx as oi}from"react/jsx-runtime";function Fe({point:t}){let e=t.entity??{};return oi("span",{className:"rle-pin",children:e.price!=null?j(e.price):""})}import{jsx as G,jsxs as we}from"react/jsx-runtime";function ke({entity:t,onClose:e}){let i=t??{};return we("div",{className:"rle-popup",role:"group","aria-label":"Location details",children:[G("button",{type:"button",onClick:e,"aria-label":"Close",className:"rle-popup-close",children:we("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:[G("path",{d:"M18 6 6 18"}),G("path",{d:"m6 6 12 12"})]})}),we("div",{children:[i.title&&G("div",{className:"rle-card-title",children:i.title}),i.subtitle&&G("div",{className:"rle-card-address",children:i.subtitle}),i.price!=null&&G("div",{className:"rle-card-price",children:j(i.price)})]})]})}import{jsx as ai}from"react/jsx-runtime";function Se({count:t,total:e}){let i=e!=null&&e!==t?`${t} of ${e} results`:`${t} results`;return ai("div",{className:"rle-result-header",children:i})}import{jsx as li}from"react/jsx-runtime";function Ce({value:t,onChange:e,placeholder:i}){return li("input",{type:"search",value:t,placeholder:i,onChange:n=>e(n.target.value),"aria-label":i??"Search",className:"rle-input"})}import{jsx as di}from"react/jsx-runtime";function Ie({children:t}){return di("aside",{className:"rle-sidebar",children:t})}import{jsx as pi}from"react/jsx-runtime";function Ee({children:t}){return pi("div",{className:"rle-toolbar",children:t})}var gt={BottomNav:ut,Card:be,Marker:Fe,Popup:ke,Sidebar:Ie,FilterPanel:Pe,Search:Ce,Empty:Le,Loading:Te,ResultHeader:Se,Toolbar:Ee};import{useEffect as xe,useRef as ui,useState as ft}from"react";import{createPortal as ci}from"react-dom";import{Fragment as gi,jsx as D,jsxs as pe}from"react/jsx-runtime";function yt({open:t,onOpenChange:e,title:i,children:n,footer:r}){let s=ui(null),[o,a]=ft(!1),[p,l]=ft(!1);return xe(()=>{if(!t){l(!1),a(!1);return}a(!0);let d=requestAnimationFrame(()=>l(!0));return()=>cancelAnimationFrame(d)},[t]),xe(()=>{if(!o)return;let d=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=d}},[o]),xe(()=>{if(!o)return;s.current?.focus();function d(m){m.key==="Escape"&&e(!1)}return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[o,e]),!o||typeof document>"u"?null:ci(pe(gi,{children:[D("div",{className:`rle-sheet-backdrop${p?" rle-sheet-backdrop--open":""}`,onClick:()=>e(!1),"aria-hidden":"true"}),pe("div",{ref:s,className:`rle-sheet${p?" rle-sheet--open":""}`,role:"dialog","aria-modal":"true","aria-label":i,tabIndex:-1,children:[D("div",{className:"rle-sheet__handle","aria-hidden":"true"}),pe("div",{className:"rle-sheet__header",children:[i&&D("div",{className:"rle-sheet__title",children:i}),D("button",{type:"button",className:"rle-sheet__close",onClick:()=>e(!1),"aria-label":"Close",children:D(mi,{})})]}),D("div",{className:"rle-sheet__body",children:n}),r&&D("div",{className:"rle-sheet__footer",children:r})]})]}),document.body)}function mi(){return pe("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"})]})}import{useEffect as ce,useRef as Re,useState as U}from"react";import{jsx as P,jsxs as ue}from"react/jsx-runtime";function ht({search:t,onFiltersClick:e,filterCount:i=0,action:n}){let{Search:r}=S();return ue("header",{className:"rle-mobile-header",children:[t&&P("div",{className:"rle-mobile-header__search",children:P(r,{value:t.value,onChange:t.onChange,placeholder:t.placeholder})}),ue("button",{type:"button",className:"rle-btn rle-mobile-header__btn",onClick:e,children:[P(fi,{}),P("span",{children:"Filters"}),i>0&&P("span",{className:"rle-mobile-header__count",children:i})]}),n&&P("button",{type:"button",className:"rle-btn rle-mobile-header__btn rle-mobile-header__btn--icon",onClick:n.onClick,"aria-label":n.label,children:n.icon??P(yi,{})})]})}function fi(){return ue("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:[P("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),P("circle",{cx:"9",cy:"6",r:"2",fill:"currentColor",stroke:"none"}),P("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),P("circle",{cx:"15",cy:"12",r:"2",fill:"currentColor",stroke:"none"}),P("line",{x1:"4",y1:"18",x2:"20",y2:"18"}),P("circle",{cx:"11",cy:"18",r:"2",fill:"currentColor",stroke:"none"})]})}function yi(){return ue("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:[P("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),P("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}import{Fragment as vt,jsx as c,jsxs as K}from"react/jsx-runtime";var hi=c("div",{className:"rle-empty",children:"Map unavailable"}),vi=c("div",{className:"rle-map-pending"});function bi(){let t=Re(null),[e,i]=U(!0),[n,r]=U(!0);return ce(()=>{let s=t.current;if(!s)return;let o=()=>{let{clientWidth:m,scrollLeft:b,scrollWidth:E}=s;i(b<=0),r(b+m>=E-1)},a=0,p=()=>{a||(a=requestAnimationFrame(()=>{a=0,o()}))};o(),s.addEventListener("scroll",o,{passive:!0});let l,d;return typeof ResizeObserver<"u"&&(l=new ResizeObserver(o),l.observe(s)),typeof MutationObserver<"u"&&(d=new MutationObserver(p),d.observe(s,{characterData:!0,childList:!0,subtree:!0})),()=>{s.removeEventListener("scroll",o),l?.disconnect(),d?.disconnect(),a&&cancelAnimationFrame(a)}},[]),{atEnd:n,atStart:e,ref:t}}function Li(t,e){if(t===e)return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;let i=t,n=e,r=new Set([...Object.keys(i),...Object.keys(n)]);for(let s of r)if(i[s]!==n[s])return!1;return!0}function bt({search:t,filterBarStart:e,resultsSlot:i,toolbarEnd:n,mobileAction:r,autoFetch:s=!0,initialPage:o,hasMap:a,mapCenter:p,mapZoom:l,mapControls:d,mapPending:m,onMapReady:b,mobileSheetFooter:E,className:_}){let F=L(),{BottomNav:B,Search:u}=S(),A=W(),{filters:x,set:V}=oe(),{pagination:g}=C(),N=a??F.map!=null,[H,q]=U("list"),[v,f]=U(!1),{atEnd:y,atStart:h,ref:R}=bi(),z=Re(null);ce(()=>{g.mode==="paged"&&z.current&&(z.current.scrollTop=0)},[g.mode,g.pageIndex]);let[T,Me]=U(x),[Pt,Tt]=U(v);v!==Pt&&(Tt(v),v&&Me(x));let De=ge=>Me(wt=>({...wt,...ge})),[Be,Oe]=U(!1),me=Re(!1);ce(()=>{if(Be){if(g.loading){me.current=!0;return}me.current&&(me.current=!1,Oe(!1),f(!1))}},[Be,g.loading]);let Q=t?{value:String(x[t.filterKey]??""),onChange:ge=>{V({[t.filterKey]:ge||void 0})},placeholder:t.placeholder}:void 0;ce(()=>{s!==!1&&(o&&o>0?F.goToPage(o):F.applyFilters({}))},[F,s]);let _e=()=>{De(F.filters.clearedParams())},Ae=()=>{if(Li(T,x)){f(!1);return}Oe(!0),F.applyFilters(T)},Ft=F.filters.activeKeys(x).length,He=A.total??A.items.length;return K("div",{className:_?`rle-app ${_}`:"rle-app",children:[K("div",{className:"rle-filter-bar",children:[K("div",{className:"rle-filter-bar__scroll",ref:R,children:[Q&&c("div",{className:"rle-filter-bar__search",children:c(u,{value:Q.value,onChange:Q.onChange,placeholder:Q.placeholder})}),e&&c("div",{className:"rle-filter-bar__slot",children:e}),c(ye,{className:"rle-filters-row",groupClassName:"rle-filter-group",hideLabels:!0})]}),!h&&c("div",{className:"rle-filter-bar__fade rle-filter-bar__fade--start","aria-hidden":"true"}),!y&&c("div",{className:"rle-filter-bar__fade rle-filter-bar__fade--end","aria-hidden":"true"})]}),c(ht,{search:Q,onFiltersClick:()=>f(!0),filterCount:Ft,action:r}),K("div",{className:`rle-body ${N?"rle-split":"rle-body--list-only"}`,"data-mobile-view":H,children:[c("div",{className:"rle-list",ref:z,children:i??K(vt,{children:[K("div",{className:"rle-list-header",children:[c(ot,{}),n&&c("div",{className:"rle-list-header__toolbar",children:n})]}),c(Ye,{className:"rle-list-grid"}),c(st,{})]})}),N&&c("div",{className:"rle-map",children:c(rt,{center:p,zoom:l,fallback:m?vi:hi,mapControls:d,onMapReady:b})})]}),N&&c(B,{view:H,onViewChange:q}),c(yt,{title:"Filters",open:v,onOpenChange:f,footer:E?E({draft:T,apply:Ae,clear:_e,resultCount:He,loading:g.loading}):K(vt,{children:[c("button",{type:"button",className:"rle-btn rle-btn--ghost",onClick:_e,children:"Clear all"}),c("button",{type:"button",className:"rle-btn rle-btn--primary rle-sheet__apply",disabled:g.loading,onClick:Ae,children:g.loading?c("span",{className:"rle-spinner","aria-label":"Updating results"}):`Show ${He} results`})]}),children:c(ye,{className:"rle-filter-stack",groupClassName:"rle-filter-group",draft:T,onDraftChange:De})})]})}import{useEffect as Pi,useRef as Ti,useState as Fi}from"react";import{jsx as Ne,jsxs as Si}from"react/jsx-runtime";function Lt(t){return"provider"in t}function wi(t){let e=t!=null&&!Lt(t),i=e?t.apiKey:void 0,n=e?t.mapId:void 0,r=e?t.mapOptions:void 0,s=e?t.styles:void 0,o=e?t.overlayMarkers:void 0,[a,p]=Fi(()=>!t||Lt(t)?{ready:!0,provider:t?.provider}:{ready:!1});return Pi(()=>{if(!i)return;let l=!1;return import("./maps/google/index.js").then(({googleProvider:d})=>{l||p({ready:!0,provider:d({apiKey:i,mapId:n,mapOptions:r,styles:s,overlayMarkers:o})})}),()=>{l=!0}},[i,n]),a}function ki({onFiltersChange:t}){let e=Ti(t);return e.current=t,at("FiltersChanged",i=>{i.type==="FiltersChanged"&&e.current(i.filters)}),null}function Wr(t){let{datasets:e,filters:i,map:n,components:r,initialFilters:s,initialResults:o,onFiltersChange:a,mobileAction:p,search:l,filterBarStart:d,resultsSlot:m,toolbarEnd:b,mapControls:E,onMapReady:_,mobileSheetFooter:F,config:B,autoFetch:u,initialPage:A,className:x}=t,{provider:V}=wi(n),g=[];for(let q of e)g.push(qe(q));i&&g.push($e(i)),V&&g.push(Ve(V)),s&&g.push(We(s)),o&&g.push(je(o)),B&&g.push(Ue(B));let N=Ke(...g),H={...gt,...r};return Si(pt,{...N,children:[a&&Ne(ki,{onFiltersChange:a}),Ne(Qe,{...H,children:Ne(bt,{className:x,search:l,filterBarStart:d,resultsSlot:m,toolbarEnd:b,mobileAction:p,autoFetch:u??o==null,hasMap:n!=null,mapCenter:n?.center,mapZoom:n?.zoom,mapControls:E,mapPending:n!=null,onMapReady:_,initialPage:A,mobileSheetFooter:F})})]})}export{ee as a,$ as b,te as c,ie as d,ze as e,ne as f,re as g,Ke as h,Ue as i,Ve as j,qe as k,$e as l,Ki as m,We as n,je as o,Ui as p,fe as q,Qe as r,S as s,se as t,L as u,C as v,oe as w,ye as x,W as y,Ye as z,rt as A,st as B,ot as C,at as D,pt as E,ut as F,be as G,Le as H,Pe as I,Te as J,Fe as K,ke as L,Se as M,Ce as N,Ie as O,Ee as P,gt as Q,yt as R,bt as S,Wr as T};
|
package/dist/chunk-YIN4LD7K.cjs
DELETED
|
@@ -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 ee= (_class =class{__init() {this.listeners=new Set}constructor(e){;_class.prototype.__init.call(this);this.state=this.freezeState({filters:{...e.filters},results:e.results?{items:[...e.results.items],nextCursor:e.results.nextCursor,total:e.results.total}:{items:[],nextCursor:null},bounds:null,selection:null,hovered:null,pagination:{mode:_nullishCoalesce(e.mode, () => ("paged")),loading:!1,loaded:e.results!=null,pageIndex:0},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},pagination:{...this.state.pagination,loaded:!0}})}appendResults(e){this.setState({results:{items:[...this.state.results.items,...e.items],nextCursor:e.nextCursor,total:e.total},pagination:{...this.state.pagination,loaded:!0}})}setBounds(e){this.setState({bounds:e?{...e}:null})}setSelection(e){this.setState({selection:e})}setHovered(e){this.setState({hovered:e})}setLayerVisible(e,i){this.setState({layers:{...this.state.layers,[e]:i}})}setLoading(e){this.setState({pagination:{...this.state.pagination,loading:e}})}setPageIndex(e){this.setState({pagination:{...this.state.pagination,pageIndex: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 $= (_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(),n=e.filter(s=>this.defs.has(s));n.forEach((s,o)=>{this.defs.get(s).order=o});let r=new Set(n);return i.filter(s=>!r.has(s.key)).forEach((s,o)=>{s.order=n.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(n=>Object.hasOwn(e,n.key)).map(n=>n.toParams(e[n.key])).reduce((n,r)=>({...n,...r}),{})}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 te= (_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 ie= (_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 r of[...i])r(e);let n=this.map.get("*");if(n)for(let r of[...n])r(e)}on(e,i){let n=this.map.get(e);return n||(n=new Set,this.map.set(e,n)),n.add(i),()=>{n.delete(i)}}}, _class4);var ze={pagination:"paged",pageSize:20,debounceMs:250};var ne=class{constructor(e){this.options=Object.freeze({...ze,...e})}};var re= (_class5 =class{__init5() {this.disposed=!1}__init6() {this.emitter=new ie}__init7() {this.debounceTimer=null}__init8() {this.debounceResolve=null}__init9() {this.queryToken=0}__init10() {this.pointsToken=0}__init11() {this.mapHandle=null}__init12() {this.pendingFit=null}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);_class5.prototype.__init10.call(this);_class5.prototype.__init11.call(this);_class5.prototype.__init12.call(this);this.datasets=e.datasets,this.filters=_nullishCoalesce(e.filters, () => (new $)),this.map=e.map,this.config=new ne(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 ee({filters:_nullishCoalesce(e.initialFilters, () => ({})),mode:this.config.options.pagination,results:e.initialResults})}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,n=this.config.options.debounceMs;return n<=0?this.runQuery(i):new Promise(r=>{this.debounceResolve=r,this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.debounceResolve=null,r(this.runQuery(i))},n)})}async loadPage(){let e=this.state.results.nextCursor;if(e===null)return;let i=++this.queryToken,n=this.primaryDataset();this.store.setLoading(!0);try{let r=await n.adapter.list(this.currentFilters(),{cursor:e,limit:this.config.options.pageSize});if(i!==this.queryToken)return;this.config.options.pagination==="infinite"?this.store.appendResults(r):this.store.setResults(r),this.emitter.emit({type:"ResultsLoaded",datasetId:this.primaryDatasetId,count:r.items.length})}finally{i===this.queryToken&&this.store.setLoading(!1)}}async goToPage(e){if(e<0)return;let i=++this.queryToken,n=this.primaryDataset();this.store.setLoading(!0);try{let r=await n.adapter.list(this.currentFilters(),{offset:e*this.config.options.pageSize,limit:this.config.options.pageSize});if(i!==this.queryToken)return;this.store.setResults(r),this.store.setPageIndex(e),this.emitter.emit({type:"ResultsLoaded",datasetId:this.primaryDatasetId,count:r.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(),n=++this.pointsToken;await Promise.allSettled(this.datasets.visibleIds().map(async r=>{let s=this.datasets.get(r);if(!s)return;let o=await s.adapter.getPoints(i,e);n===this.pointsToken&&this.store.setPoints(r,o)}))}setMapHandle(e){if(this.mapHandle=e,!e||!this.pendingFit||!this.map)return;let{bounds:i,options:n}=this.pendingFit;this.pendingFit=null,this.map.fitBounds(e,i,n)}fitBounds(e,i){if(this.map){if(!this.mapHandle){this.pendingFit={bounds:e,options:i};return}this.map.fitBounds(this.mapHandle,e,i)}}selectPoint(e,i){this.store.setSelection(i);let n=_optionalChain([this, 'access', _11 => _11.state, 'access', _12 => _12.points, 'access', _13 => _13[e], 'optionalAccess', _14 => _14.find, 'call', _15 => _15(r=>r.id===i)]);n&&this.emitter.emit({type:"PointClicked",datasetId:e,id:n.id,entity:n.entity})}setHovered(e,i){this.store.setHovered(i)}toggleLayer(e){let n=!(_nullishCoalesce(this.state.layers[e], () => (!0)));this.store.setLayerVisible(e,n),this.emitter.emit({type:"LayerToggled",datasetId:e,visible:n})}subscribe(e){return this.store.subscribe(e)}on(e,i){return this.emitter.on(e,i)}get isDisposed(){return this.disposed}attachMap(e){this.disposed||this.map===e||this.map||(this.map=e,this.store.setFilters({}))}dispose(){this.clearDebounce(),this.emitter.dispose(),this.mapHandle=null,this.disposed=!0}async runQuery(e){if(e!==this.queryToken)return;let i=this.primaryDataset();this.store.setLoading(!0);try{let n=await i.adapter.list(this.currentFilters(),{cursor:null,limit:this.config.options.pageSize});if(e!==this.queryToken)return;this.store.setResults(n),this.store.setPageIndex(0),this.emitter.emit({type:"ResultsLoaded",datasetId:this.primaryDatasetId,count:n.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 Ke(...t){let e={config:{},filters:new $,datasets:new te};for(let i of t)i(e);return e}var Ue=t=>e=>{e.config={...e.config,...t}},Ve= exports.j =t=>e=>{e.map=t},qe= exports.k =t=>e=>{e.datasets.add(t)},$e= exports.l =t=>e=>{t(e.filters)},Ki= exports.m =t=>e=>{e.urlSync=t},We= exports.n =t=>e=>{e.initialFilters=t},je= exports.o =t=>e=>{e.initialResults=t},Ui= exports.p =t=>e=>{e.primaryDatasetId=t};var _react = require('react');var _jsxruntime = require('react/jsx-runtime');function Ct(t){return String(_nullishCoalesce(_optionalChain([t, 'optionalAccess', _16 => _16.title]), () => ("")))}var It=({item:t})=>_jsxruntime.jsx.call(void 0, "div",{children:Ct(t)}),Et=()=>_jsxruntime.jsx.call(void 0, "div",{}),fe= exports.q =()=>_jsxruntime.jsx.call(void 0, "div",{}),xt=({children:t})=>_jsxruntime.jsx.call(void 0, "div",{children:t}),Rt=({children:t})=>_jsxruntime.jsx.call(void 0, "div",{children:t}),Nt=({value:t,onChange:e,placeholder:i})=>_jsxruntime.jsx.call(void 0, "input",{type:"search",value:t,placeholder:i,onChange:n=>e(n.target.value),"aria-label":_nullishCoalesce(i, () => ("Search"))}),Mt=()=>_jsxruntime.jsx.call(void 0, "div",{role:"status",children:"No results"}),Dt=()=>_jsxruntime.jsx.call(void 0, "div",{role:"status","aria-busy":"true",children:"Loading\u2026"}),Bt=({count:t})=>_jsxruntime.jsxs.call(void 0, "div",{children:[t," results"]}),Ot=({children:t})=>_jsxruntime.jsx.call(void 0, "div",{children:t}),_t=({view:t,onViewChange:e})=>_jsxruntime.jsxs.call(void 0, "nav",{"aria-label":"Listing navigation",children:[_jsxruntime.jsx.call(void 0, "button",{type:"button","aria-pressed":t==="list",onClick:()=>e("list"),children:"List"}),_jsxruntime.jsx.call(void 0, "button",{type:"button","aria-pressed":t==="map",onClick:()=>e("map"),children:"Map"})]}),w={BottomNav:_t,Card:It,Marker:Et,Popup:fe,Sidebar:xt,FilterPanel:Rt,Search:Nt,Empty:Mt,Loading:Dt,ResultHeader:Bt,Toolbar:Ot},Ge=_react.createContext.call(void 0, w);function Qe(t){let{BottomNav:e,Card:i,Marker:n,Popup:r,Sidebar:s,FilterPanel:o,Search:a,Empty:p,Loading:l,ResultHeader:d,Toolbar:m,children:b}=t,E={BottomNav:_nullishCoalesce(e, () => (w.BottomNav)),Card:_nullishCoalesce(i, () => (w.Card)),Marker:_nullishCoalesce(n, () => (w.Marker)),Popup:_nullishCoalesce(r, () => (w.Popup)),Sidebar:_nullishCoalesce(s, () => (w.Sidebar)),FilterPanel:_nullishCoalesce(o, () => (w.FilterPanel)),Search:_nullishCoalesce(a, () => (w.Search)),Empty:_nullishCoalesce(p, () => (w.Empty)),Loading:_nullishCoalesce(l, () => (w.Loading)),ResultHeader:_nullishCoalesce(d, () => (w.ResultHeader)),Toolbar:_nullishCoalesce(m, () => (w.Toolbar))};return _jsxruntime.jsx.call(void 0, Ge.Provider,{value:E,children:b})}function S(){return _react.useContext.call(void 0, Ge)}var se=_react.createContext.call(void 0, null);function L(){let t=_react.useContext.call(void 0, se);if(t===null)throw new Error("useListing must be used within a <ListingProvider>");return t}function C(){let t=L(),e=_react.useCallback.call(void 0, n=>t.subscribe(n),[t]),i=_react.useCallback.call(void 0, ()=>t.state,[t]);return _react.useSyncExternalStore.call(void 0, e,i,i)}function oe(){let t=L(),e=C(),i=_react.useCallback.call(void 0, r=>t.applyFilters(r),[t]),n=_react.useCallback.call(void 0, (r,s)=>t.applyFilters({[r]:s}),[t]);return{filters:e.filters,set:i,setField:n}}function ye({className:t,groupClassName:e,hideLabels:i,draft:n,onDraftChange:r}={}){let s=L(),{FilterPanel:o}=S(),{filters:a}=oe(),p=n!==void 0&&r!==void 0,l=p?n:a;return _jsxruntime.jsx.call(void 0, o,{children:_jsxruntime.jsx.call(void 0, "div",{className:_nullishCoalesce(t, () => ("space-y-5")),children:s.filters.list().map(d=>{if(typeof d.render=="string")return _jsxruntime.jsx.call(void 0, "div",{"data-filter":d.key,className:e},d.key);let m=d.render;return _jsxruntime.jsxs.call(void 0, "div",{className:e,children:[d.label&&!i&&_jsxruntime.jsx.call(void 0, "div",{className:"mb-1.5 text-[13px] font-medium text-foreground",children:d.label}),_jsxruntime.jsx.call(void 0, m,{value:d.fromParams(l),onChange:b=>p?r(d.toParams(b)):void s.applyFilters(d.toParams(b))})]},d.key)})})})}function W(){return C().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 Ye({className:t}={}){let e=L(),{items:i}=W(),{pagination:n,selection:r}=C(),{Card:s,Empty:o,Loading:a}=S();return i.length===0&&(n.loading||!n.loaded)?_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((p,l)=>{let d=Ut(p,l);return _jsxruntime.jsx.call(void 0, s,{item:p,selected:r===d,onSelect:()=>e.selectPoint(e.primaryDatasetId,d)},d)})})}var _reactdom = require('react-dom');var qt={west:-179.9,south:-85,east:179.9,north:85},tt=.1,it=.02;function $t(t){if(t.length===0)return null;let e=t[0].lng,i=t[0].lng,n=t[0].lat,r=t[0].lat;for(let{lat:a,lng:p}of t)p<e&&(e=p),p>i&&(i=p),a<n&&(n=a),a>r&&(r=a);let s=r>n?(r-n)*tt:it,o=i>e?(i-e)*tt:it;return{west:e-o,east:i+o,south:n-s,north:r+s}}function rt(t){let{center:e,zoom:i,fallback:n,mapControls:r,onMapReady:s}=t,o=L(),a=C(),p=_react.useRef.call(void 0, s);p.current=s;let l=_react.useRef.call(void 0, null),d=_react.useRef.call(void 0, null),m=_react.useRef.call(void 0, null),[b,E]=_react.useState.call(void 0, !1),_=_react.useRef.call(void 0, !1),F=_react.useRef.call(void 0, !1),B=_react.useRef.call(void 0, !1),u=o.map;_react.useEffect.call(void 0, ()=>{let v=m.current;if(!u||!v)return;let f=[];for(let y of Object.keys(a.points)){if(a.layers[y]===!1)continue;let h=o.datasets.get(y),R=_nullishCoalesce(a.points[y], () => ([])),z={id:y,markers:R.map(T=>({id:T.id,position:T.position,iconUrl:_optionalChain([h, 'optionalAccess', _17 => _17.marker, 'access', _18 => _18.iconUrl, 'optionalCall', _19 => _19(T.entity)]),element:_optionalChain([h, 'optionalAccess', _20 => _20.marker, 'access', _21 => _21.element, 'optionalCall', _22 => _22(T.entity)])})),clustering:_optionalChain([h, 'optionalAccess', _23 => _23.clustering]),onMarkerClick:T=>o.selectPoint(y,T)};f.push(u.renderLayer(v,z))}return()=>{f.forEach(y=>y())}},[o,u,b,a.points,a.layers]),_react.useEffect.call(void 0, ()=>{if(!l.current||!u)return;let v=l.current,f=!1,y=null;return(async()=>{let h=await u.mount(v,{center:e,zoom:i,fullscreenTarget:_nullishCoalesce(d.current, () => (void 0))});if(f){u.destroy(h);return}m.current=h,o.setMapHandle(h),y=u.onBoundsChange(h,R=>{B.current?B.current=!1:F.current=!0,o.loadPoints(R)}),E(!0),_optionalChain([p, 'access', _24 => _24.current, 'optionalCall', _25 => _25(_nullishCoalesce(h.nativeMap, () => (h.raw)))]),o.loadPoints(qt)})(),()=>{f=!0,_optionalChain([y, 'optionalCall', _26 => _26()]),m.current&&(u.destroy(m.current),m.current=null,o.setMapHandle(null),_optionalChain([p, 'access', _27 => _27.current, 'optionalCall', _28 => _28(null)])),E(!1)}},[o,u]),_react.useEffect.call(void 0, ()=>{let v=m.current;if(!u||!v||e||_.current||F.current)return;let f=[];for(let h of Object.keys(a.points))if(a.layers[h]!==!1)for(let R of _nullishCoalesce(a.points[h], () => ([])))f.push(R.position);let y=$t(f);y&&(_.current=!0,B.current=!0,u.fitBounds(v,y))},[u,e,b,a.points,a.layers]),_react.useEffect.call(void 0, ()=>{_optionalChain([u, 'optionalAccess', _29 => _29.updateMarkerStates, 'call', _30 => _30(a.selection,a.hovered)])},[u,b,a.selection,a.hovered]);let{Popup:A}=S(),x=A!==fe,V=_nullishCoalesce(a.points[o.primaryDatasetId], () => ([])),g=a.selection!=null?V.find(v=>v.id===a.selection):void 0,[N,H]=_react.useState.call(void 0, null),q=_react.useRef.call(void 0, g);return q.current=g,_react.useEffect.call(void 0, ()=>{let v=m.current;if(!u||!v||!x)return;let f=q.current;if(!f)return;let y=u.mountOverlay(f.position);H({entity:f.entity,position:f.position,container:y.container});let h=()=>o.selectPoint(o.primaryDatasetId,null),R=T=>{T.key==="Escape"&&h()};document.addEventListener("keydown",R);let z=u.onMapClick(h);return()=>{document.removeEventListener("keydown",R),z(),y.unmount(),H(null)}},[o,u,b,a.selection,x]),_jsxruntime.jsxs.call(void 0, "div",{ref:d,className:"relative h-full min-h-0 w-full",children:[_jsxruntime.jsxs.call(void 0, "div",{ref:l,className:!u&&n?"flex h-full min-h-0 w-full items-center justify-center":"h-full min-h-0 w-full",children:[!u&&n,x&&N?_reactdom.createPortal.call(void 0, _jsxruntime.jsx.call(void 0, A,{entity:N.entity,onClose:()=>o.selectPoint(o.primaryDatasetId,null)}),N.container):null]}),r!=null&&_jsxruntime.jsx.call(void 0, "div",{className:"pointer-events-none absolute inset-0",children:_jsxruntime.jsx.call(void 0, "div",{className:"pointer-events-auto",children:r})})]})}var ve="gap";function Wt(t,e){if(t<=7)return Array.from({length:t},(s,o)=>o+1);let i=Math.max(2,e-1),n=Math.min(t-1,e+1),r=[1];i>2&&r.push(ve);for(let s=i;s<=n;s+=1)r.push(s);return n<t-1&&r.push(ve),r.push(t),r}function st(){let t=L(),{results:e,pagination:i}=C();if(i.mode==="infinite")return e.nextCursor==null?null:_jsxruntime.jsx.call(void 0, "button",{type:"button",disabled:i.loading,onClick:()=>{t.loadPage()},children:"Load more"});let n=t.options.pageSize,{pageIndex:r}=i,s=r+1,o=e.total!=null?Math.ceil(e.total/n):null,a=o!=null?s<o:e.nextCursor!=null||e.items.length>=n;if(o!=null?o<=1:r===0&&!a)return null;let p=l=>()=>{t.goToPage(l)};return _jsxruntime.jsxs.call(void 0, "nav",{className:"rle-pagination","aria-label":"Pagination",children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"rle-page-btn rle-page-btn--nav","aria-label":"Previous page",disabled:i.loading||r===0,onClick:p(r-1),children:"\u2039"}),o!=null&&Wt(o,s).map((l,d)=>l===ve?_jsxruntime.jsx.call(void 0, "span",{className:"rle-page-ellipsis",children:"\u2026"},`gap-${d}`):_jsxruntime.jsx.call(void 0, "button",{type:"button",className:l===s?"rle-page-btn rle-page-btn--active":"rle-page-btn","aria-label":`Page ${l}`,"aria-current":l===s?"page":void 0,disabled:i.loading,onClick:p(l-1),children:l},l)),_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"rle-page-btn rle-page-btn--nav","aria-label":"Next page",disabled:i.loading||!a,onClick:p(r+1),children:"\u203A"})]})}function ot(){let{items:t,total:e}=W(),{ResultHeader:i}=S();return _jsxruntime.jsx.call(void 0, i,{count:t.length,total:e})}function at(t,e){let i=L(),n=_react.useRef.call(void 0, e);n.current=e,_react.useEffect.call(void 0, ()=>i.on(t,r=>n.current(r)),[i,t])}function pt(t){let{children:e,...i}=t,[n]=_react.useState.call(void 0, ()=>i),r=_react.useCallback.call(void 0, ()=>new re({datasets:n.datasets,filters:n.filters,config:n.config,map:n.map,initialFilters:n.initialFilters,initialResults:n.initialResults,primaryDatasetId:n.primaryDatasetId}),[n]),[s,o]=_react.useState.call(void 0, r),a=_react.useRef.call(void 0, s);a.current=s;let p=i.map;return _react.useEffect.call(void 0, ()=>{p&&s.attachMap(p)},[s,p]),_react.useEffect.call(void 0, ()=>{let l=a.current;return l.isDisposed&&(l=r(),a.current=l,o(l)),n.urlSync&&n.urlSync.start(l),()=>{n.urlSync&&n.urlSync.stop(),l.dispose()}},[n,r]),_jsxruntime.jsx.call(void 0, se.Provider,{value:s,children:e})}function ut({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, ei,{}),"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, ti,{}),"Map"]})]})})}function ei(){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 ti(){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"})]})}function j(t){return typeof t!="number"?t:new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t)}function ii(t){return t?"rle-card rle-card--selected":"rle-card"}function be({item:t,selected:e,onSelect:i}){let n=_nullishCoalesce(t, () => ({})),r=ii(e),s=_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[n.imageUrl?_jsxruntime.jsx.call(void 0, "img",{src:n.imageUrl,alt:_nullishCoalesce(n.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:[n.title&&_jsxruntime.jsx.call(void 0, "span",{className:"rle-card-title",children:n.title}),n.subtitle&&_jsxruntime.jsx.call(void 0, "span",{className:"rle-card-address",children:n.subtitle}),n.badge&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-card-info",children:_jsxruntime.jsx.call(void 0, "span",{className:"rle-card-info-item",children:n.badge})}),n.price!=null&&_jsxruntime.jsx.call(void 0, "span",{className:"rle-card-price",children:j(n.price)})]})]});return i?_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:i,"aria-pressed":_nullishCoalesce(e, () => (!1)),className:r,children:s}):_jsxruntime.jsx.call(void 0, "article",{className:r,children:s})}function Le(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 Pe({children:t}){return _jsxruntime.jsx.call(void 0, "div",{className:"rle-filter-panel",children:t})}function Te(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 Fe({point:t}){let e=_nullishCoalesce(t.entity, () => ({}));return _jsxruntime.jsx.call(void 0, "span",{className:"rle-pin",children:e.price!=null?j(e.price):""})}function ke({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:j(i.price)})]})]})}function Se({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 Ce({value:t,onChange:e,placeholder:i}){return _jsxruntime.jsx.call(void 0, "input",{type:"search",value:t,placeholder:i,onChange:n=>e(n.target.value),"aria-label":_nullishCoalesce(i, () => ("Search")),className:"rle-input"})}function Ie({children:t}){return _jsxruntime.jsx.call(void 0, "aside",{className:"rle-sidebar",children:t})}function Ee({children:t}){return _jsxruntime.jsx.call(void 0, "div",{className:"rle-toolbar",children:t})}var gt={BottomNav:ut,Card:be,Marker:Fe,Popup:ke,Sidebar:Ie,FilterPanel:Pe,Search:Ce,Empty:Le,Loading:Te,ResultHeader:Se,Toolbar:Ee};function yt({open:t,onOpenChange:e,title:i,children:n,footer:r}){let s=_react.useRef.call(void 0, null),[o,a]=_react.useState.call(void 0, !1),[p,l]=_react.useState.call(void 0, !1);return _react.useEffect.call(void 0, ()=>{if(!t){l(!1),a(!1);return}a(!0);let d=requestAnimationFrame(()=>l(!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', _31 => _31.current, 'optionalAccess', _32 => _32.focus, 'call', _33 => _33()]);function d(m){m.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${p?" rle-sheet-backdrop--open":""}`,onClick:()=>e(!1),"aria-hidden":"true"}),_jsxruntime.jsxs.call(void 0, "div",{ref:s,className:`rle-sheet${p?" 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, mi,{})})]}),_jsxruntime.jsx.call(void 0, "div",{className:"rle-sheet__body",children:n}),r&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-sheet__footer",children:r})]})]}),document.body)}function mi(){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 ht({search:t,onFiltersClick:e,filterCount:i=0,action:n}){let{Search:r}=S();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, r,{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, fi,{}),_jsxruntime.jsx.call(void 0, "span",{children:"Filters"}),i>0&&_jsxruntime.jsx.call(void 0, "span",{className:"rle-mobile-header__count",children:i})]}),n&&_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"rle-btn rle-mobile-header__btn rle-mobile-header__btn--icon",onClick:n.onClick,"aria-label":n.label,children:_nullishCoalesce(n.icon, () => (_jsxruntime.jsx.call(void 0, yi,{})))})]})}function fi(){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 yi(){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 hi=_jsxruntime.jsx.call(void 0, "div",{className:"rle-empty",children:"Map unavailable"}),vi=_jsxruntime.jsx.call(void 0, "div",{className:"rle-map-pending"});function bi(){let t=_react.useRef.call(void 0, null),[e,i]=_react.useState.call(void 0, !0),[n,r]=_react.useState.call(void 0, !0);return _react.useEffect.call(void 0, ()=>{let s=t.current;if(!s)return;let o=()=>{let{clientWidth:m,scrollLeft:b,scrollWidth:E}=s;i(b<=0),r(b+m>=E-1)},a=0,p=()=>{a||(a=requestAnimationFrame(()=>{a=0,o()}))};o(),s.addEventListener("scroll",o,{passive:!0});let l,d;return typeof ResizeObserver<"u"&&(l=new ResizeObserver(o),l.observe(s)),typeof MutationObserver<"u"&&(d=new MutationObserver(p),d.observe(s,{characterData:!0,childList:!0,subtree:!0})),()=>{s.removeEventListener("scroll",o),_optionalChain([l, 'optionalAccess', _34 => _34.disconnect, 'call', _35 => _35()]),_optionalChain([d, 'optionalAccess', _36 => _36.disconnect, 'call', _37 => _37()]),a&&cancelAnimationFrame(a)}},[]),{atEnd:n,atStart:e,ref:t}}function Li(t,e){if(t===e)return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;let i=t,n=e,r=new Set([...Object.keys(i),...Object.keys(n)]);for(let s of r)if(i[s]!==n[s])return!1;return!0}function bt({search:t,filterBarStart:e,resultsSlot:i,toolbarEnd:n,mobileAction:r,autoFetch:s=!0,initialPage:o,hasMap:a,mapCenter:p,mapZoom:l,mapControls:d,mapPending:m,onMapReady:b,mobileSheetFooter:E,className:_}){let F=L(),{BottomNav:B,Search:u}=S(),A=W(),{filters:x,set:V}=oe(),{pagination:g}=C(),N=_nullishCoalesce(a, () => (F.map!=null)),[H,q]=_react.useState.call(void 0, "list"),[v,f]=_react.useState.call(void 0, !1),{atEnd:y,atStart:h,ref:R}=bi(),z=_react.useRef.call(void 0, null);_react.useEffect.call(void 0, ()=>{g.mode==="paged"&&z.current&&(z.current.scrollTop=0)},[g.mode,g.pageIndex]);let[T,Me]=_react.useState.call(void 0, x),[Pt,Tt]=_react.useState.call(void 0, v);v!==Pt&&(Tt(v),v&&Me(x));let De=ge=>Me(wt=>({...wt,...ge})),[Be,Oe]=_react.useState.call(void 0, !1),me=_react.useRef.call(void 0, !1);_react.useEffect.call(void 0, ()=>{if(Be){if(g.loading){me.current=!0;return}me.current&&(me.current=!1,Oe(!1),f(!1))}},[Be,g.loading]);let Q=t?{value:String(_nullishCoalesce(x[t.filterKey], () => (""))),onChange:ge=>{V({[t.filterKey]:ge||void 0})},placeholder:t.placeholder}:void 0;_react.useEffect.call(void 0, ()=>{s!==!1&&(o&&o>0?F.goToPage(o):F.applyFilters({}))},[F,s]);let _e=()=>{De(F.filters.clearedParams())},Ae=()=>{if(Li(T,x)){f(!1);return}Oe(!0),F.applyFilters(T)},Ft=F.filters.activeKeys(x).length,He=_nullishCoalesce(A.total, () => (A.items.length));return _jsxruntime.jsxs.call(void 0, "div",{className:_?`rle-app ${_}`:"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:R,children:[Q&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-filter-bar__search",children:_jsxruntime.jsx.call(void 0, u,{value:Q.value,onChange:Q.onChange,placeholder:Q.placeholder})}),e&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-filter-bar__slot",children:e}),_jsxruntime.jsx.call(void 0, ye,{className:"rle-filters-row",groupClassName:"rle-filter-group",hideLabels:!0})]}),!h&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-filter-bar__fade rle-filter-bar__fade--start","aria-hidden":"true"}),!y&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-filter-bar__fade rle-filter-bar__fade--end","aria-hidden":"true"})]}),_jsxruntime.jsx.call(void 0, ht,{search:Q,onFiltersClick:()=>f(!0),filterCount:Ft,action:r}),_jsxruntime.jsxs.call(void 0, "div",{className:`rle-body ${N?"rle-split":"rle-body--list-only"}`,"data-mobile-view":H,children:[_jsxruntime.jsx.call(void 0, "div",{className:"rle-list",ref:z,children:_nullishCoalesce(i, () => (_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsxs.call(void 0, "div",{className:"rle-list-header",children:[_jsxruntime.jsx.call(void 0, ot,{}),n&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-list-header__toolbar",children:n})]}),_jsxruntime.jsx.call(void 0, Ye,{className:"rle-list-grid"}),_jsxruntime.jsx.call(void 0, st,{})]})))}),N&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-map",children:_jsxruntime.jsx.call(void 0, rt,{center:p,zoom:l,fallback:m?vi:hi,mapControls:d,onMapReady:b})})]}),N&&_jsxruntime.jsx.call(void 0, B,{view:H,onViewChange:q}),_jsxruntime.jsx.call(void 0, yt,{title:"Filters",open:v,onOpenChange:f,footer:E?E({draft:T,apply:Ae,clear:_e,resultCount:He,loading:g.loading}):_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.jsx.call(void 0, "button",{type:"button",className:"rle-btn rle-btn--primary rle-sheet__apply",disabled:g.loading,onClick:Ae,children:g.loading?_jsxruntime.jsx.call(void 0, "span",{className:"rle-spinner","aria-label":"Updating results"}):`Show ${He} results`})]}),children:_jsxruntime.jsx.call(void 0, ye,{className:"rle-filter-stack",groupClassName:"rle-filter-group",draft:T,onDraftChange:De})})]})}function Lt(t){return"provider"in t}function wi(t){let e=t!=null&&!Lt(t),i=e?t.apiKey:void 0,n=e?t.mapId:void 0,r=e?t.mapOptions:void 0,s=e?t.styles:void 0,o=e?t.overlayMarkers:void 0,[a,p]=_react.useState.call(void 0, ()=>!t||Lt(t)?{ready:!0,provider:_optionalChain([t, 'optionalAccess', _38 => _38.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:d})=>{l||p({ready:!0,provider:d({apiKey:i,mapId:n,mapOptions:r,styles:s,overlayMarkers:o})})}),()=>{l=!0}},[i,n]),a}function ki({onFiltersChange:t}){let e=_react.useRef.call(void 0, t);return e.current=t,at("FiltersChanged",i=>{i.type==="FiltersChanged"&&e.current(i.filters)}),null}function Wr(t){let{datasets:e,filters:i,map:n,components:r,initialFilters:s,initialResults:o,onFiltersChange:a,mobileAction:p,search:l,filterBarStart:d,resultsSlot:m,toolbarEnd:b,mapControls:E,onMapReady:_,mobileSheetFooter:F,config:B,autoFetch:u,initialPage:A,className:x}=t,{provider:V}=wi(n),g=[];for(let q of e)g.push(qe(q));i&&g.push($e(i)),V&&g.push(Ve(V)),s&&g.push(We(s)),o&&g.push(je(o)),B&&g.push(Ue(B));let N=Ke(...g),H={...gt,...r};return _jsxruntime.jsxs.call(void 0, pt,{...N,children:[a&&_jsxruntime.jsx.call(void 0, ki,{onFiltersChange:a}),_jsxruntime.jsx.call(void 0, Qe,{...H,children:_jsxruntime.jsx.call(void 0, bt,{className:x,search:l,filterBarStart:d,resultsSlot:m,toolbarEnd:b,mobileAction:p,autoFetch:_nullishCoalesce(u, () => (o==null)),hasMap:n!=null,mapCenter:_optionalChain([n, 'optionalAccess', _39 => _39.center]),mapZoom:_optionalChain([n, 'optionalAccess', _40 => _40.zoom]),mapControls:E,mapPending:n!=null,onMapReady:_,initialPage:A,mobileSheetFooter:F})})]})}exports.a = ee; exports.b = $; exports.c = te; exports.d = ie; exports.e = ze; exports.f = ne; exports.g = re; exports.h = Ke; exports.i = Ue; exports.j = Ve; exports.k = qe; exports.l = $e; exports.m = Ki; exports.n = We; exports.o = je; exports.p = Ui; exports.q = fe; exports.r = Qe; exports.s = S; exports.t = se; exports.u = L; exports.v = C; exports.w = oe; exports.x = ye; exports.y = W; exports.z = Ye; exports.A = rt; exports.B = st; exports.C = ot; exports.D = at; exports.E = pt; exports.F = ut; exports.G = be; exports.H = Le; exports.I = Pe; exports.J = Te; exports.K = Fe; exports.L = ke; exports.M = Se; exports.N = Ce; exports.O = Ie; exports.P = Ee; exports.Q = gt; exports.R = yt; exports.S = bt; exports.T = Wr;
|