react-listing-engine 0.12.3 → 0.12.4

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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # react-listing-engine
2
2
 
3
+ ## 0.12.4
4
+
5
+ ### Patch Changes
6
+
7
+ - The list's empty state now requires a COMPLETED query -- an unseeded boot renders `Loading`, never `Empty`.
8
+
9
+ `ListingList` showed the injected `Empty` ("No results") whenever `items` was empty and nothing was in flight -- which is also the state of a freshly-booted, unseeded engine that has not issued its first query yet (waiting on map bounds, for instance). Server-rendered, that claim reached crawlers as the page's actual content. The store's pagination state gains `loaded`: false until a results commit (`setResults`/`appendResults`), true from a seeded init (a server already ran that query), never reset. `ListingList` renders `Loading` while `!loaded`, and `Empty` is reserved for a committed answer that really contained nothing.
10
+
3
11
  ## 0.12.3
4
12
 
5
13
  ### Patch Changes
@@ -0,0 +1,2 @@
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;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){this.mapHandle=e}fitBounds(e,i){!this.map||!this.mapHandle||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};
@@ -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 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}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);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){this.mapHandle=e}fitBounds(e,i){!this.map||!this.mapHandle||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;
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 _chunkLQU6EWU4cjs = require('./chunk-LQU6EWU4.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}=_chunkLQU6EWU4cjs.s.call(void 0, );return _jsxruntime.jsx.call(void 0, t,{children:e})}var _react = require('react');function yt(){let e=_chunkLQU6EWU4cjs.u.call(void 0, ),t=_chunkLQU6EWU4cjs.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=_chunkLQU6EWU4cjs.u.call(void 0, ),r=_chunkLQU6EWU4cjs.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 = _chunkLQU6EWU4cjs.c; exports.FallbackPopup = _chunkLQU6EWU4cjs.q; exports.FilterRegistry = _chunkLQU6EWU4cjs.b; exports.ListingApp = _chunkLQU6EWU4cjs.T; exports.ListingComponentsProvider = _chunkLQU6EWU4cjs.r; exports.ListingConfig = _chunkLQU6EWU4cjs.f; exports.ListingEngine = _chunkLQU6EWU4cjs.g; exports.ListingEngineContext = _chunkLQU6EWU4cjs.t; exports.ListingEventType = v; exports.ListingFilters = _chunkLQU6EWU4cjs.x; exports.ListingList = _chunkLQU6EWU4cjs.z; exports.ListingMap = _chunkLQU6EWU4cjs.A; exports.ListingPagination = _chunkLQU6EWU4cjs.B; exports.ListingProvider = _chunkLQU6EWU4cjs.E; exports.ListingResultHeader = _chunkLQU6EWU4cjs.C; exports.ListingStore = _chunkLQU6EWU4cjs.a; exports.ListingToolbar = it; exports.MemoryHistoryPort = h; exports.PaginationMode = b; exports.TypedEmitter = _chunkLQU6EWU4cjs.d; exports.UrlSyncController = f; exports.composeListingProviders = _chunkLQU6EWU4cjs.h; exports.listingDefaultConfig = _chunkLQU6EWU4cjs.e; exports.useListing = _chunkLQU6EWU4cjs.u; exports.useListingComponents = _chunkLQU6EWU4cjs.s; exports.useListingEvent = _chunkLQU6EWU4cjs.D; exports.useListingFilters = _chunkLQU6EWU4cjs.w; exports.useListingLayer = ft; exports.useListingMap = yt; exports.useListingResults = _chunkLQU6EWU4cjs.y; exports.useListingState = _chunkLQU6EWU4cjs.v; exports.withConfig = _chunkLQU6EWU4cjs.i; exports.withDataset = _chunkLQU6EWU4cjs.k; exports.withFilters = _chunkLQU6EWU4cjs.l; exports.withInitialFilters = _chunkLQU6EWU4cjs.n; exports.withInitialResults = _chunkLQU6EWU4cjs.o; exports.withMap = _chunkLQU6EWU4cjs.j; exports.withPrimaryDataset = _chunkLQU6EWU4cjs.p; exports.withUrlSync = _chunkLQU6EWU4cjs.m;
2
+ var _chunkSNH3BB4Scjs = require('./chunk-SNH3BB4S.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}=_chunkSNH3BB4Scjs.s.call(void 0, );return _jsxruntime.jsx.call(void 0, t,{children:e})}var _react = require('react');function yt(){let e=_chunkSNH3BB4Scjs.u.call(void 0, ),t=_chunkSNH3BB4Scjs.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=_chunkSNH3BB4Scjs.u.call(void 0, ),r=_chunkSNH3BB4Scjs.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 = _chunkSNH3BB4Scjs.c; exports.FallbackPopup = _chunkSNH3BB4Scjs.q; exports.FilterRegistry = _chunkSNH3BB4Scjs.b; exports.ListingApp = _chunkSNH3BB4Scjs.T; exports.ListingComponentsProvider = _chunkSNH3BB4Scjs.r; exports.ListingConfig = _chunkSNH3BB4Scjs.f; exports.ListingEngine = _chunkSNH3BB4Scjs.g; exports.ListingEngineContext = _chunkSNH3BB4Scjs.t; exports.ListingEventType = v; exports.ListingFilters = _chunkSNH3BB4Scjs.x; exports.ListingList = _chunkSNH3BB4Scjs.z; exports.ListingMap = _chunkSNH3BB4Scjs.A; exports.ListingPagination = _chunkSNH3BB4Scjs.B; exports.ListingProvider = _chunkSNH3BB4Scjs.E; exports.ListingResultHeader = _chunkSNH3BB4Scjs.C; exports.ListingStore = _chunkSNH3BB4Scjs.a; exports.ListingToolbar = it; exports.MemoryHistoryPort = h; exports.PaginationMode = b; exports.TypedEmitter = _chunkSNH3BB4Scjs.d; exports.UrlSyncController = f; exports.composeListingProviders = _chunkSNH3BB4Scjs.h; exports.listingDefaultConfig = _chunkSNH3BB4Scjs.e; exports.useListing = _chunkSNH3BB4Scjs.u; exports.useListingComponents = _chunkSNH3BB4Scjs.s; exports.useListingEvent = _chunkSNH3BB4Scjs.D; exports.useListingFilters = _chunkSNH3BB4Scjs.w; exports.useListingLayer = ft; exports.useListingMap = yt; exports.useListingResults = _chunkSNH3BB4Scjs.y; exports.useListingState = _chunkSNH3BB4Scjs.v; exports.withConfig = _chunkSNH3BB4Scjs.i; exports.withDataset = _chunkSNH3BB4Scjs.k; exports.withFilters = _chunkSNH3BB4Scjs.l; exports.withInitialFilters = _chunkSNH3BB4Scjs.n; exports.withInitialResults = _chunkSNH3BB4Scjs.o; exports.withMap = _chunkSNH3BB4Scjs.j; exports.withPrimaryDataset = _chunkSNH3BB4Scjs.p; exports.withUrlSync = _chunkSNH3BB4Scjs.m;
package/dist/index.d.cts CHANGED
@@ -22,6 +22,7 @@ interface ListingState<TEntity, TFilters> {
22
22
  pagination: {
23
23
  mode: PaginationMode;
24
24
  loading: boolean;
25
+ loaded: boolean;
25
26
  pageIndex: number;
26
27
  };
27
28
  layers: Record<string, boolean>;
@@ -207,6 +208,7 @@ declare class ListingEngine<TEntity, TFilters> {
207
208
  readonly pagination: {
208
209
  readonly mode: PaginationMode;
209
210
  readonly loading: boolean;
211
+ readonly loaded: boolean;
210
212
  readonly pageIndex: number;
211
213
  };
212
214
  readonly layers: {
@@ -524,9 +526,13 @@ interface IListingFiltersProps<TFilters = unknown> {
524
526
  declare function ListingFilters<TFilters = unknown>({ className, groupClassName, hideLabels, draft, onDraftChange, }?: IListingFiltersProps<TFilters>): react.JSX.Element;
525
527
 
526
528
  /**
527
- * Structure-only results list. Renders the injected `Loading` while the
528
- * first page is still in flight, `Empty` once settled with nothing, and
529
- * otherwise one injected `Card` per result item.
529
+ * Structure-only results list. Renders the injected `Loading` until the list
530
+ * has something to say -- both while a page is in flight AND before any
531
+ * query has ever committed (`pagination.loaded`): an unseeded boot is "not
532
+ * asked yet", and rendering `Empty` for it would claim a verified absence
533
+ * that no query produced (server-rendered, that claim even reaches crawlers).
534
+ * `Empty` is reserved for a COMPLETED query with nothing in it; otherwise
535
+ * one injected `Card` renders per result item.
530
536
  *
531
537
  * `onSelect` routes through `engine.selectPoint(engine.primaryDatasetId, id)`
532
538
  * -- the only mutator for `state.selection` -- rather than a list-only
@@ -821,6 +827,7 @@ declare function useListingState<TEntity = unknown, TFilters = unknown>(): {
821
827
  readonly pagination: {
822
828
  readonly mode: PaginationMode;
823
829
  readonly loading: boolean;
830
+ readonly loaded: boolean;
824
831
  readonly pageIndex: number;
825
832
  };
826
833
  readonly layers: {
package/dist/index.d.ts CHANGED
@@ -22,6 +22,7 @@ interface ListingState<TEntity, TFilters> {
22
22
  pagination: {
23
23
  mode: PaginationMode;
24
24
  loading: boolean;
25
+ loaded: boolean;
25
26
  pageIndex: number;
26
27
  };
27
28
  layers: Record<string, boolean>;
@@ -207,6 +208,7 @@ declare class ListingEngine<TEntity, TFilters> {
207
208
  readonly pagination: {
208
209
  readonly mode: PaginationMode;
209
210
  readonly loading: boolean;
211
+ readonly loaded: boolean;
210
212
  readonly pageIndex: number;
211
213
  };
212
214
  readonly layers: {
@@ -524,9 +526,13 @@ interface IListingFiltersProps<TFilters = unknown> {
524
526
  declare function ListingFilters<TFilters = unknown>({ className, groupClassName, hideLabels, draft, onDraftChange, }?: IListingFiltersProps<TFilters>): react.JSX.Element;
525
527
 
526
528
  /**
527
- * Structure-only results list. Renders the injected `Loading` while the
528
- * first page is still in flight, `Empty` once settled with nothing, and
529
- * otherwise one injected `Card` per result item.
529
+ * Structure-only results list. Renders the injected `Loading` until the list
530
+ * has something to say -- both while a page is in flight AND before any
531
+ * query has ever committed (`pagination.loaded`): an unseeded boot is "not
532
+ * asked yet", and rendering `Empty` for it would claim a verified absence
533
+ * that no query produced (server-rendered, that claim even reaches crawlers).
534
+ * `Empty` is reserved for a COMPLETED query with nothing in it; otherwise
535
+ * one injected `Card` renders per result item.
530
536
  *
531
537
  * `onSelect` routes through `engine.selectPoint(engine.primaryDatasetId, id)`
532
538
  * -- the only mutator for `state.selection` -- rather than a list-only
@@ -821,6 +827,7 @@ declare function useListingState<TEntity = unknown, TFilters = unknown>(): {
821
827
  readonly pagination: {
822
828
  readonly mode: PaginationMode;
823
829
  readonly loading: boolean;
830
+ readonly loaded: boolean;
824
831
  readonly pageIndex: number;
825
832
  };
826
833
  readonly layers: {
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-7IBFFLO2.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};
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-SMVY5LXY.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});"use client";
2
- var _chunkLQU6EWU4cjs = require('../chunk-LQU6EWU4.cjs');var _jsxruntime = require('react/jsx-runtime');function L({children:o}){return _jsxruntime.jsx.call(void 0, _chunkLQU6EWU4cjs.r,{..._chunkLQU6EWU4cjs.Q,children:o})}exports.BottomNav = _chunkLQU6EWU4cjs.F; exports.BottomSheet = _chunkLQU6EWU4cjs.R; exports.ListingApp = _chunkLQU6EWU4cjs.T; exports.StyledCard = _chunkLQU6EWU4cjs.G; exports.StyledComponentsProviderWithDefaults = L; exports.StyledEmpty = _chunkLQU6EWU4cjs.H; exports.StyledFilterPanel = _chunkLQU6EWU4cjs.I; exports.StyledListingLayout = _chunkLQU6EWU4cjs.S; exports.StyledLoading = _chunkLQU6EWU4cjs.J; exports.StyledMarker = _chunkLQU6EWU4cjs.K; exports.StyledPopup = _chunkLQU6EWU4cjs.L; exports.StyledResultHeader = _chunkLQU6EWU4cjs.M; exports.StyledSearch = _chunkLQU6EWU4cjs.N; exports.StyledSidebar = _chunkLQU6EWU4cjs.O; exports.StyledToolbar = _chunkLQU6EWU4cjs.P; exports.styledDefaultComponents = _chunkLQU6EWU4cjs.Q;
2
+ var _chunkSNH3BB4Scjs = require('../chunk-SNH3BB4S.cjs');var _jsxruntime = require('react/jsx-runtime');function L({children:o}){return _jsxruntime.jsx.call(void 0, _chunkSNH3BB4Scjs.r,{..._chunkSNH3BB4Scjs.Q,children:o})}exports.BottomNav = _chunkSNH3BB4Scjs.F; exports.BottomSheet = _chunkSNH3BB4Scjs.R; exports.ListingApp = _chunkSNH3BB4Scjs.T; exports.StyledCard = _chunkSNH3BB4Scjs.G; exports.StyledComponentsProviderWithDefaults = L; exports.StyledEmpty = _chunkSNH3BB4Scjs.H; exports.StyledFilterPanel = _chunkSNH3BB4Scjs.I; exports.StyledListingLayout = _chunkSNH3BB4Scjs.S; exports.StyledLoading = _chunkSNH3BB4Scjs.J; exports.StyledMarker = _chunkSNH3BB4Scjs.K; exports.StyledPopup = _chunkSNH3BB4Scjs.L; exports.StyledResultHeader = _chunkSNH3BB4Scjs.M; exports.StyledSearch = _chunkSNH3BB4Scjs.N; exports.StyledSidebar = _chunkSNH3BB4Scjs.O; exports.StyledToolbar = _chunkSNH3BB4Scjs.P; exports.styledDefaultComponents = _chunkSNH3BB4Scjs.Q;
@@ -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-7IBFFLO2.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};
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-SMVY5LXY.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-listing-engine",
3
- "version": "0.12.3",
3
+ "version": "0.12.4",
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,6 +80,14 @@
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
+ },
83
91
  "devDependencies": {
84
92
  "@changesets/cli": "^2.31.1",
85
93
  "@googlemaps/js-api-loader": "^2.1.1",
@@ -103,13 +111,5 @@
103
111
  },
104
112
  "publishConfig": {
105
113
  "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
+ }
@@ -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,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}})}appendResults(e){this.setState({results:{items:[...this.state.results.items,...e.items],nextCursor:e.nextCursor,total:e.total}})}setBounds(e){this.setState({bounds:e?{...e}:null})}setSelection(e){this.setState({selection:e})}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;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){this.mapHandle=e}fitBounds(e,i){!this.map||!this.mapHandle||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 n.loading&&i.length===0?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};
@@ -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,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}})}appendResults(e){this.setState({results:{items:[...this.state.results.items,...e.items],nextCursor:e.nextCursor,total:e.total}})}setBounds(e){this.setState({bounds:e?{...e}:null})}setSelection(e){this.setState({selection:e})}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}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);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){this.mapHandle=e}fitBounds(e,i){!this.map||!this.mapHandle||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 n.loading&&i.length===0?_jsxruntime.jsx.call(void 0, a,{}):i.length===0?_jsxruntime.jsx.call(void 0, o,{}):_jsxruntime.jsx.call(void 0, "div",{role:"list",className:t,children:i.map((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;